c# - Authorizing partial web methods -


i using asmx web services (not wcf) , implemented simple http module basic authentication. works fine authorizing files (web.config deny/allow) , user.isinrole filled.

however, want authorize partial web methods. purpose, found principalpermission.demand atributes. however, allways throws exception although passed valid login credentials.

web config:

    <system.webserver>     <modules>         <add name="authenticationmodule" type="authenticationmodule"/>     </modules> </system.webserver> <system.web>         <authentication mode="none"/>     <authorization>         <allow users="*" />     </authorization> </system.web> 

client:

commonservice.commonservices service = new commonservice.commonservices();                service.credentials = new networkcredential(username, pass);                 service.preauthenticate = true;                 service.helloworldforeveryone(); 

it throws:

unhandled exception: system.web.services.protocols.soapexception: system.web.serv ices.protocols.soapexception:     v system.security.permissions.principalpermission.throwsecurityexception()    v system.security.permissions.principalpermission.demand()    v system.security.permissionset.demandnoncas()    v wsautentization.commonservices.helloworldforeveryone() in commonservices.asmx.cs:řádek 30    v system.web.services.protocols.soaphttpclientprotocol.readresponse(soapclien tmessage message, webresponse response, stream responsestream, boolean asynccall )    v system.web.services.protocols.soaphttpclientprotocol.invoke(string methodna me, object[] parameters)    v console.commonservice.commonservices.helloworldforeveryone() v d:\tmp\wsaut entization\console\web references\commonservice\reference.cs:řádek 93    v console.program.main(string[] args) v d:\tmp\wsautentization\console\progra m.cs:line 35 

is there way how authorize partial web methods?

thanks lot!

principalpermission checked against thread.currentprincipal. don't see code in authentication module, had same problems , solution set

thread.currentprincipal = httpcontext.current.user; 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -