473,789 Members | 2,876 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing a Share Using Windows Credentials

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\sha re" 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
Mar 17 '06 #1
3 8468
Carl wrote:
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\sha re" 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
Mar 17 '06 #2
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

"Chris" wrote:
Carl wrote:
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\sha re" 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

Mar 17 '06 #3
Carl wrote:
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

"Chris" wrote:

Carl wrote:
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\sha re" 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


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.../24/39479.aspx

Chris
Mar 17 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
2910
by: Lamberti Fabrizio | last post by:
Hi all, I've to access to a network file from an asp pages. I've red a lot of things on old posts and on Microsoft article but I can't still solve my problem. I've got two server inside the same NT domain, each one has its own web server. The web server is always IIS 5.0.
36
16419
by: Thomas | last post by:
after spending countless hours trying, i give up and hope to get some help in here. on server1 i got the web myweb.com with my test.asp. in the test.asp, i'm trying to read a file from an UNC path with a FSO: Set myFile = Server.CreateObject("Scripting.FileSystemObject").GetFile("\\server2\myshare\myfile.txt") this fails with an Permission Denied. here's the deal:
3
13361
by: Bonj | last post by:
I need to write a windows service, and the only way it can access a shared drive on a file server on the network is if the installer is put in "User" mode - "LocalService", "LocalSystem" and "NetworkService" don't work. i.e. it can't access the shared drive. But in "User" it can. But I don't want it in user mode, if possible. I would rather it be a service. Is there any way to do it?
0
2266
by: Joergen Bech | last post by:
Fairly new to ASP.NET 1.1. Getting the error below when running application on a web server outside of my control, but only the first time I run it: 1. After a long period of inactivity (or updating the code-behind dll) accessing any aspx page in the application causes the application to run for the first time. Some of the initialization involves reading and writing some text and xml files using simple streamreader and streamwriter...
11
3076
by: Andre | last post by:
Hi, I have ASP.NET application running on standalone (not part of the domain) Windows 2003. I use forms authentication for my application. The problem I have is that I need to create and read files on Windows domain network shared drives and also on shared via Samba Unix drives, which is equivalent to writing/reading to the workgroup computer. Please point, if possible, to detailed step by step description of what needs to be done. Thank...
5
2809
by: Khalique | last post by:
Hi everyone, I Hope that someone will be able to give me a hint to the solution to my problem. I have developed a web service (vb.net) that needs to access the folders / files and copy files to and from the public folder on the client machine. It is not a public web service, only accessible on intranet. The anonymous access is disabled. Windows authentication is enabled. Web.Config sets <identity impersonate="true" /> Using a test app,...
4
3783
by: Khalique | last post by:
I have built a web service whose purpose is to copy files from a secure place to client machine and vice versa. The problem I am having is perhaps related to permissions and access rights. For testing purposes, the secure place is setup on the client machine. The client (window app) calls the web service (on a different machine) and connects successfully to the web service. However, when client calls a method that copies the file from...
1
1920
by: riyaz.shaikh | last post by:
Hi All.... I am having a web site which runs under Windows Authentication. the requirement is this application should write files to a folder share. but the problem is this folder share is accessible by only one User say (Domain/User1). where as the we application will be used by all other users. So whenever I try accessing the folder using the current users identity it gives an UnAuthorized exception... How can I impersonate in a web...
1
5479
by: Usenet User | last post by:
From a .NET 1.1 app: need to access a file share on a remote server by its UNC path, i.e., \\server\folder\subfolder\, using specific username and password. The problem is that the credentials are local to the remote server. Therefore, impersonating that user when accessing the share is not possible. One solution is to map a network drive using the credentials, but it seems kind of ugly and old school.
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10199
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6768
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.