c# network login
How do I perform a network login, to access a shared driver for instance, programmatically in c#? The same can be achieved by either attempting to open a share through the explorer, or by the net use shell command.
P/Invoke call to WNetAddConnection2 will do the trick. Look here for more info.
[DllImport("mpr.dll")]
public static extern int WNetAddConnection2A
(
[MarshalAs(UnmanagedType.LPArray)] NETRESOURCEA[] lpNetResource,
[MarshalAs(UnmanagedType.LPStr)] string lpPassword,
[MarshalAs(UnmanagedType.LPStr)] string UserName, int dwFlags
);
您需要使用Windows Identity Impersonation,查看这些链接http://blogs.msdn.com/shawnfa/archive/2005/03/21/400088.aspx http://blogs.msdn.com/saurabhkv /archive/2008/05/29/windowsidentity-impersonation-using-c-code.aspx
链接地址: http://www.djcxy.com/p/6118.html上一篇: 如何在C#中复制整个目录的内容?
下一篇: c#网络登录
