Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
352 Points
219 Posts
Apr 06, 2012 06:37 PM|LINK
I am trying to impersonation a user in my C# code to open a file share in Windows Explorer. BUT IT IS NOT WORKING! My code is below.
Impersonator i = new Impersonator(); using (new Impersonator("userA", "domainA", "pa$$word", LogonType.LOGON32_LOGON_INTERACTIVE, LogonProvider.LOGON32_PROVIDER_DEFAULT)) { Process.Start(@"c:\windows\explorer.exe", @"\\fileshare\abc"); Response.Write("Impersonated User: " + WindowsIdentity.GetCurrent().Name + "<br />"); Response.Write("Logon User: " + Request.ServerVariables["LOGON_USER"] + "<br />"); Response.Write("Authenticated User: " + Request.ServerVariables["AUTH_USER"] + "<br />"); }
I am using the code to do the impersonation from this site:
http://platinumdogs.wordpress.com/2008/10/30/net-c-impersonation-with-network-credentials/
I am thinking it is because the Logon & Authenticated is my windows login because I am using Windows Authentication?
The account I am impersonating is a domain account and has full account to the file share.
Please help
ADDITIONAL:
I also tried using this code but it did not work. I got an "Access Denied" error
string target = "'_blank'"; string script = "window.open(" + @"'file://fileshare/abc'" + "," + target + "," + "'status=no, menubar=yes, toolbar=yes');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "someUniqueId", script, true);
kjmcad
Member
352 Points
219 Posts
ASP.NET Impersonation
Apr 06, 2012 06:37 PM|LINK
I am trying to impersonation a user in my C# code to open a file share in Windows Explorer. BUT IT IS NOT WORKING! My code is below.
Impersonator i = new Impersonator(); using (new Impersonator("userA", "domainA", "pa$$word", LogonType.LOGON32_LOGON_INTERACTIVE, LogonProvider.LOGON32_PROVIDER_DEFAULT)) { Process.Start(@"c:\windows\explorer.exe", @"\\fileshare\abc"); Response.Write("Impersonated User: " + WindowsIdentity.GetCurrent().Name + "<br />"); Response.Write("Logon User: " + Request.ServerVariables["LOGON_USER"] + "<br />"); Response.Write("Authenticated User: " + Request.ServerVariables["AUTH_USER"] + "<br />"); }I am using the code to do the impersonation from this site:
http://platinumdogs.wordpress.com/2008/10/30/net-c-impersonation-with-network-credentials/
I am thinking it is because the Logon & Authenticated is my windows login because I am using Windows Authentication?
The account I am impersonating is a domain account and has full account to the file share.
Please help
ADDITIONAL:
I also tried using this code but it did not work. I got an "Access Denied" error
string target = "'_blank'"; string script = "window.open(" + @"'file://fileshare/abc'" + "," + target + "," + "'status=no, menubar=yes, toolbar=yes');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "someUniqueId", script, true);