• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 756
  • Last Modified:

Dir of UNC path passing credentials... .Net 2.0 3.0 or 3.5

I have a program that needs to do a dir on a unc path.  This path will need username / password to get to.

How do I go about his in VB.Net?

Thanks,

Rog
0
Rog D
Asked:
Rog D
1 Solution
 
wdosanjosCommented:
You need to Impersonate the user in question.  Please check the sample code on the page below.  Your dir code should go in the Using impersonatedUser As WindowsImpersonationContext = newId.Impersonate() block.  Remove all the Console.Write and you should be good to go.

http://msdn.microsoft.com/en-us/library/w070t6ka.aspx

I hope this helps.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now