Solved

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

Posted on 2011-03-08
1
741 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
[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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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