This aspect of Windows file sharing is a total pain. The file access client has all sorts of horrible session state, in order to provide an environment that resembles that under DOS/Win3x networking.
You can use WNetAddConnection2 or WNetAddConnection3 to connect a local drive letter to a remote share, or just to provide credentials for access to a given remote share. The method signature is trival; access through P/Invoke should be easy. At this point, of course, it's just a Win32 issue. -- arlie -----Original Message----- From: Moderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Janis Braslins Sent: Tuesday, January 13, 2004 2:20 PM To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] Providing credentials in order to access files on network file shares Hmm, any ideas? I really would like to go away from this WSH hack. Thanx :) ----- Original Message ------- I need to be able to access files on password proteceted network file shares from my ASP.NET app. The username, password and DOMAIN are loaded from the secure database at runtime. I'd like to use System.IO File and Directory classes to work with files and directories on those shares. I was planning on using UNC names for file/directory path (something like \\server\share\path\file.ext). How can I specify username, password and domain to use when accessing such UNC path using System.IO? Giving ASP.NET account necessary rights or changing the ASP.NET account impersonation is not an option. For time being I've added a reference to the Windows Scripting Host object and am using WshShell component to execute command line commands like 'net use \\server\share password /u:user\domain' which would map to the share when needed. Is there a native .NET way of doing this without using WSH? Thank you :) =================================== This list is hosted by DevelopMentorR http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com
