DFPITC
asked on
Problems reading UNC paths from impersonated asp.net using vb
Basically, i'm trying to write a file to people's home directory using VB/ASP.NET
I run this code:
(note: M_Util.Debug_Write is a function that writes to a file I can tail/read)
I run this code:
(note: M_Util.Debug_Write is a function that writes to a file I can tail/read)
Dim wi As WindowsIdentity = CType(User.Identity, WindowsIdentity)
M_Util.Debug_Write(wi.GetCurrent().Name)
M_Util.Debug_Write(System.Threading.Thread.CurrentPrincipal.Identity.Name)
Dim wic As WindowsImpersonationContext = wi.Impersonate()
M_Util.Debug_Write(wi.GetCurrent().Name)
M_Util.Debug_Write(System.Threading.Thread.CurrentPrincipal.Identity.Name)
M_Util.Debug_Write(Directory.Exists(Server.MapPath("/"))) 'Web server app root
M_Util.Debug_Write(Directory.Exists("C:\")) 'web server c
M_Util.Debug_Write(Directory.Exists("\\myfileserver\transit")) 'transit drive share
M_Util.Debug_Write(Directory.Exists("\\10.0.0.40\transit")) 'transit drive share (by ip)
M_Util.Debug_Write(Directory.Exists("\\10.0.0.40\transit\test")) 'transit drive folder (by ip)
M_Util.Debug_Write(Directory.Exists("\\mypc\c$")) 'my pc
M_Util.Debug_Write(Directory.Exists("\\10.0.0.51\c$"))'my pc (ip)
wic.Undo()
M_Util.Debug_Write(wi.GetCurrent().Name)
M_Util.Debug_Write(System.Threading.Thread.CurrentPrincipal.Identity.Name)
and it outputs this:"NT AUTHORITY\NETWORK SERVICE"
"MYDOMAIN\myuser"
"MYDOMAIN\myuser"
"MYDOMAIN\myuser"
"True"
"True"
"False"
"False"
"False"
"False"
"False"
"NT AUTHORITY\NETWORK SERVICE"
"MYDOMAIN\myuser"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This answered my question:
http://forums.asp.net/p/1347272/2756134.aspx
Basically, the impersonation only works when using it on the webserver.
http://forums.asp.net/p/1347272/2756134.aspx
Basically, the impersonation only works when using it on the webserver.
ASKER
No luck of course