c# - Custom authorize and authentication using operationcontext in wcf -
i created wcf service below custom authentication
public class restauthorizationmanager: serviceauthorizationmanager { protected override bool checkaccesscore(operationcontext operationcontext) { //extract authorization header, , parse out credentials converting base64 string: var authheader = weboperationcontext.current.incomingrequest.headers["authorization"]; if ((authheader != null) && (authheader != string.empty)) { var svccredentials = system.text.asciiencoding.ascii .getstring(convert.frombase64string(authheader.substring(6))) .split(':'); var user = new { name = svccredentials[0], password = svccredentials[1] }; if ((user.name == "1" && user.password == "1")) { //user authrized , originating call proceed string role = getfromdatabase(user.name); if(role==?????????) return true; } else { //not authorized return false; } } else { throw new webfaultexception(httpstatuscode.unauthorized); } } } as can see check username , password ,if result true role database string role = getfromdatabase(user.name);.
but want check operation role user role.i don't know how can access operation role [principalpermission(securityaction.demand, role = "admin")] here admin ,in checkaccesscore function?
Comments
Post a Comment