Thanks, that looks like it nearly does the trick - only problem is I'm using C# and for some reason can't get the syntax right??
See below for what I'm doing
Any ideas????
Main Topics
Browse All TopicsHi,
I'm building a bit of software that will be accessing files that are hosted on MS Share point. When I map a network drive (Z:\....) and access the file using this path - it all works fine. Problem is when I try to put the network path (\\Cintranet\....) it falis with an exception of 'Logon Failed'
My guess is that when i'm using the network drive Windows automatically sends a usrname and password to gain access... Question is how do I retrieve this information programatically and send this to the Server to gain access?
Any help would be great!!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Sorry made. I assumed you were building a web app. My mistake. Here is another option
http://csharptuning.blogsp
and you may also want to look at this
http://mikehadlow.blogspot
You will have to enable following policies for the user which is trying to access the network resource.
Open Gpedit.msc->Computer Configuration->Windows Settings->Security Settings->Local Policies->User Rights Assignment
And add your user to following policies:
Log on as batch job
Also use LOGON32_LOGON_NETWORK flag in LogOnUser function
Thanks that worked... but its still not doing what I need - this is probably my fault for not understanding what I need. That code allows me to impersonate other users and do things on my local machine.
Problem is when I try to access a file using UNC path the Server that is holding the file still doesn't recognise the process is being carried out a real user - hence its failing.
So... I need to impersonate the current user to the server at the point I try and access the file
I've re-attached my original code to explain..
Thanks
Does the user account that you are using for impersonation has permissions on that file on the server? In other words does the same account exist there on the server.
The quickest way to make things work is to have a standard low rights user on Server on the user. and have a similar user on your user machine with same password. This will make life easier for you.
Interesting.. When using 3 I'm getting a different error
"The network path was not found".-- I removed the double backslashes of the variable and put in Windows Explorer and it does exist
And when using 4 or LOGON32_LOGON_BATCH I get...
"Token cannot be zero." -- reffering to the access token - It musn't be getting set to a value when I pass it onto the function...
Any ideas??
Business Accounts
Answer for Membership
by: DaTribePosted on 2009-02-20 at 01:32:23ID: 23690286
Try using impersonation where the user you are using has access to that domain.
/KB/aspnet / UNC__Acce ss_Network _file.aspx
http://www.codeproject.com