Accessing a Share Using Windows Credentials

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Using VB .NET how can I enable my program to access a share on another
machine and pass the user name and password. I have a computer and share,
say "\\computer\share" so I can copy files from it but to access it I have to
log on with a UserName and Password. I do not want the user to have to enter
the user name or password, so how can I pass this in code?

Thanks,
-Carl
 
Carl said:
Using VB .NET how can I enable my program to access a share on another
machine and pass the user name and password. I have a computer and share,
say "\\computer\share" so I can copy files from it but to access it I have to
log on with a UserName and Password. I do not want the user to have to enter
the user name or password, so how can I pass this in code?

Thanks,
-Carl


Is the username/password on the remote computer the same as the user
running the VB program? If it is, it should pass the credentials
automatically. If it is not, adding the user to the remote computer
using the same password should fix it. Otherwise you will have to
impersonate a user in the vb.net program.

Chris
 
The username/password are not the same as the user running my program so I do
need to use impersonation. How do I do that and then access a file on that
other computer using the impersonated windows account? Is there some sample
code that does this I could look at?

Thanks,
-Carl
 
Carl said:
The username/password are not the same as the user running my program so I do
need to use impersonation. How do I do that and then access a file on that
other computer using the impersonated windows account? Is there some sample
code that does this I could look at?

Thanks,
-Carl

:

Once the impersonation is done you should be able to access shares just
like you wanted to.

Do a web search for impersonation, I haven't had to do it in a long time
so I don't have any code for you. There are lots of examples around,
most will deal with ASP.NET, but the process is identical.

This article looks promising, they've made a wrapper for doing the
impersonation.

http://weblogs.asp.net/ralfw/archive/2003/11/24/39479.aspx

Chris
 
Back
Top