I have an ASP.NET site that must use Forms Authentication and not Windows Authentication to access a ActiveDirectoryMembershipProvider
. The site must use forms because they need a designed input form instead of the browser authentication popup that Windows authentication uses.
The site needs to impersonate the user logged in via Active Directory to access user specific files.
However, the WindowsIdentity.GetCurrent()
is not the same as the HttpContext.Current.User.Identity
although my web.config contains:
<authentication mode="Forms">
<forms loginUrl="login.aspx" timeout="480"/>
</authentication>
<identity impersonate="true" />
I cannot use LoginUser()
and the WindowsIdentity.Impersonate()
because I need to impersonate as the AD user to get their specific permissions, and I don't know the user's password because Forms takes care of logging in.
Is it possible maybe from the login.aspx.cs, to take the System.Web.UI.WebControls.Login.Password
, then save the LoginUser()
token in a session variable for WindowsIdentity.Impersonate()
later? Or maybe a much more secure method of Impersonating the right way?
I'm confused why Forms authentication can't automatically <identity impersonate="true" />
I've read this http://msdn.microsoft.com/en-us/library/ms998351.aspx but it uses Windows Authentication.