简体   繁体   中英

C# Web Service Impersonation

If I enable impersonation in a web service with identity="someID"... As web service is MTA application the impersonation that is applied may be applied to a worker thread and not the thread that actually call the method... I guess you might get an access denied error...Without problematically doing impersonation.. just by enabling it in webconfig.. what changes will i have to make to my function which does some clever stuff?

<identity impersonate="true" userName="DomainName\UserName" 
                         password="ClearTextPassword" />

The <identity> element within Web.config supports optional user name and password attributes which allows you to configure a specific fixed identity for your Web service to impersonate. This is shown in the following configuration file fragment... what else do i need to write?

System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcesses(); 
p.GetExccutiong();
Console.WriteLine();

IMO, the best way to configure the identity of a web-service is via the host - IIS, for example. In IIS, you can configure this via the app-pool identity ( like in this answer) . No need for plain-text passwords, and no need for hacky code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM