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

Authentication using the NetworkCredential class in .Net

Hi

I'm trying to write an application that reads files off a network share.  The problem is that the domain requires authentication before the application may access the share.  I'm trying to use the NetworkCredential class to automate this.  I have the appropriate username and password.

Please assist me in using the Network Credential class to achieve this.

I have attached some code

Thanks

'Dim NetC As New System.Net.NetworkCredential
 
        'NetC.Domain = "PRODDOM"
        'NetC.UserName = "admin-s1038920"
        'NetC.Password = "YY9hJ90!hH$"
 
 
         --This prompts for username and password
        Chart1.SaveImage(My.Settings.ImageTargetPath & My.Settings.SaveToImageName, _
                         DataVisualization.Charting.ChartImageFormat.Jpeg)

Open in new window

0
PantoffelSlippers
Asked:
PantoffelSlippers
  • 4
  • 2
1 Solution
 
PantoffelSlippersAuthor Commented:
Anyone?
0
 
Bob LearnedCommented:
Are you talking about impersonation?
0
 
PantoffelSlippersAuthor Commented:
TheLearnedOne,

To be honest with you:  I don't know.

I basically don't know what could be a solution for me.

All I'm looking to do is programmtically access a shared folder.

If authentication is required then my code needs to provide it automatically.

If impersonation can help me achieve that then yes, we can have a look at impersonation.

I've just read a couple of articles on impersonation and it seems as if it could be what I'm looking for!
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Bob LearnedCommented:
There are plenty of examples that use impersonation to access a network share.

Here is a C# CodeProject article:

Windows Impersonation using C#
http://www.codeproject.com/KB/cs/cpimpersonation1.aspx

0
 
PantoffelSlippersAuthor Commented:
Thank you TheLearnedOne,

I was unfamiliar with Impersonation up until now.

Well, I still am but at least now I know about it.

I'll check out the link  - maybe it'll solve my problem.

Post back soon

Thanks
0
 
PantoffelSlippersAuthor Commented:
Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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