Re: Setting impersonation values programmatically



The "canonical" sample is shown in the .NET Framework MSDN reference on the
WindowsImpersonationContext class documentation. You can basically copy and
paste that. There are some subtle flaws in this implementation, and Shawn
Farkas has written more about how to do this "the right way" on his blog.
Google will find it.

Joe K.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
"itmanager" <itmanager@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9305AC35-7F87-4506-B3C5-83F17F898699@xxxxxxxxxxxxxxxx
We have an ASP.NET application (v1.1) that requires some impersonation in
order to access network shares.

We have the following setting in the web.config file:

<identity impersonate="true" />

This allows the application to access network shares if the web site is
using Basic or Integrated Windows authentication; however, when using
Anonymous Authentication, it fails unless we also specify a user name and
password in clear text within the file; ie:

<identity impersonate="true"

userName="domain\user"
password="password" />

Due to security concerns, we do not want to specify this information in
clear text.

Is there a way to impersonate a particular user programmatically rather
than
entering the value in the web.config file? Can this be done without
resorting
to impersonation within a service?

Thanks for any assistance.



.