.NET Framework Access to Remote File Share

Does anyone know of any .NET classes or techniques for accessing a remote file share on a different domain without using calls to unmanaged Windows API dlls?

I have a .NET application running on a machine in domain A that needs to access a share on a machine in domain B. I'm trying to find a way to connect to the domain B share and provide the necessary credentials without requiring user intervention. An interactive user would simply access "\\domainB\sharename" and enter credentials when prompted, such as "domainB\username" & "password".

I've seen some solutions that involve calls to advapi32.dll (to create an authentication token) or mpr.dll (to create a drive mapping), but I'd like to accomplish the task within the context of the .NET Framework if possible. Actually, in my case, I don't think the advapi32.dll LogonUser strategy would even work, since the Domain A machine shouldn't be able to produce an authentication token for a Domain B account.

If no such .NET classes exist, does anyone know of a specific reason why not?

[1175 byte] By [renskemo] at [2007-12-22]
# 1
I'm fairly certain you will have to go the LogonUser route. There are some good samples on Pinvoke.net( http://www.pinvoke.net/default.aspx/advapi32/LogonUser.html).
JaredParsonsMSFT at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 2

Thanks for the input Jason. I've done some additional testing with the LogonUser method, and confirmed that it won't work for my purposes. It doesn't work to call LogonUser("username","domainB","password",etc...) from the machine in Domain A because it doesn't know about Domain B accounts. It just errors on a bad username/password.

That said, maybe I'm only left with a call to WNetAddConnection2 in the "mpr.dll" library to simulate mapping a drive?

No pure .NET implementation?

renskemo at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 3
Nope, not in the CLR (yet). You'll have to use P/Invoke. Use the forums' search tool to find a few threads that talk about or use this Google query...

nobugz at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Base Class Library...

.NET Development

Site Classified