Solved

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

Posted on 2011-03-08
1
731 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 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

23 Experts available now in Live!

Get 1:1 Help Now