Reputation: 91
I have the following code which only works when nr.lpRemoteName server part is specified with IP address.
When it's host name ERROR_SESSION_CREDENTIAL_CONFLICT will be returned.
I can access the file using host name from the machine that this code runs in.
Any ideas?
[DllImport("Mpr.dll")]
private static extern int WNetUseConnection(
IntPtr hwndOwner,
NETRESOURCE lpNetResource,
string lpPassword,
string lpUserID,
int dwFlags,
string lpAccessName,
string lpBufferSize,
string lpResult
);
[StructLayout(LayoutKind.Sequential)]
private class NETRESOURCE
{
public int dwScope = 0;
public int dwType = 0;
public int dwDisplayType = 0;
public int dwUsage = 0;
public string lpLocalName = "";
public string lpRemoteName = "";
public string lpComment = "";
public string lpProvider = "";
}
string password = "12345";
string username = "ole1";
const int RESOURCETYPE_DISK = 0x00000001;
NETRESOURCE nr = new NETRESOURCE();
nr.dwType = RESOURCETYPE_DISK;
nr.lpRemoteName = @"\\[IP Address]\vids";
//nr.lpRemoteName = @"[Host Name]\vids";
int ret = WNetUseConnection(IntPtr.Zero, nr, password, username, 0, null, null, null);
Upvotes: 3
Views: 2639
Reputation: 380
It means your Windows login session already has a connection to that host, except that connection passed a different value in the [username] parameter.
1219 (0x4C3)
Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resource and try again.
Possible solutions:
Upvotes: 1