Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problems reading UNC paths from impersonated asp.net using vb

Posted on 2012-03-25
3
Medium Priority
?
417 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1500 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

610 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