मैं एक समस्या में भाग रहा हूं जब मैं WNetAddConnection2 को उस मशीन पर कॉल करने का प्रयास करता हूं जिसमें मेरे पास पहले से सत्र है। इसकी अपेक्षा की जाती है, क्योंकि आप केवल एक संसाधन संसाधन से कनेक्ट कर सकते हैं जिसमें केवल एक सेट प्रमाण-पत्र हैं। जो मैं करने की कोशिश कर रहा हूं वह इस स्थिति को पकड़ लेता है और सभी मौजूदा कनेक्शन डिस्कनेक्ट करने के लिए स्वचालित रूप से WNetCancelConnection2 को कॉल करता है और फिर WNetAddConnection2 कॉल को पुनः प्रयास करता है। जब मैं नीचे दिए गए कोड को चलाने मैं इन लॉग संदेश प्राप्त:WNetAddConnection2 और त्रुटि 1219 - स्वचालित रूप से डिस्कनेक्ट करें?
DEBUG - WNetAddConnection2 returned 1219
DEBUG - Multiple credentials detected, disconnecting all current sessions
DEBUG - WNetCancelConnection2 returned 0
DEBUG - WNetAddConnection2 returned 1219
अगर मैं WNetCancelConnection में CONNECT_UPDATE_PROFILE को dwFlags सेट मैं इन लॉग संदेश प्राप्त:
DEBUG - WNetAddConnection2 returned 1219
DEBUG - Multiple credentials detected, disconnecting all current sessions
DEBUG - WNetCancelConnection2 returned 2250
DEBUG - WNetAddConnection2 returned 1219
यहाँ मेरी स्रोत है, सभी मदद की सराहना की है!
networkName = @"\\192.168.1.1";
var netResource = new NetResource()
{
Scope = ResourceScope.GlobalNetwork,
ResourceType = ResourceType.Disk,
DisplayType = ResourceDisplaytype.Share,
RemoteName = networkName
};
int result = WNetAddConnection2(netResource, credentials.Password, credentials.UserName, 0);
log.Debug("WNetAddConnection2 returned " + result);
if (result == 1219)
{
log.Debug("Multiple credentials detected, disconnecting all current sessions");
result = WNetCancelConnection2(networkName, 0, true);
log.Debug("WNetCancelConnection2 returned " + result);
result = WNetAddConnection2(netResource, credentials.Password, credentials.UserName, 0);
log.Debug("WNetAddConnection2 returned " + result);
}