Solved

Problems reading UNC paths from impersonated asp.net using vb

Posted on 2012-03-25
3
404 Views
Last Modified: 2012-03-26
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)
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)

Open in new window

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"

Open in new window

0
Comment
Question by:DFPITC
  • 2
3 Comments
 

Author Comment

by:DFPITC
ID: 37763962
it's worth also noting that i've tried just writing to a text file in all those locations just in case it was the Directory.Exists command

No luck of course
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 37765014
0
 

Author Comment

by:DFPITC
ID: 37765588
This answered my question:
http://forums.asp.net/p/1347272/2756134.aspx

Basically, the impersonation only works when using it on the webserver.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now