Solved

Problems reading UNC paths from impersonated asp.net using vb

Posted on 2012-03-25
3
402 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ASP.Net Session State alternatives 3 27
JavaScript error 1 33
VB.NET HttpWebRequest 12 30
Format column on datatable 7 17
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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 video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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