Solved

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

Posted on 2011-03-08
1
740 Views
Last Modified: 2012-05-11
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
Comment
Question by:Rog
1 Comment
 
LVL 23

Accepted Solution

by:
wdosanjos earned 500 total points
ID: 35073657
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.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

792 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