Unfortunately, there are several drawbacks inherent in the WNetAddConnection2 function, and they are as follows:
- If any connection has already been established to the target server by any process running on the client computer, the WNetAddConnection2 function cannot make a new connection under any credentials other than those used for the existing connection.
If you try to authenticate a new account, you will get a conflicting credentials error. If you try to authenticate the existing account, any password will work (valid or not). This is a particular problem when you are getting objects from a domain controller where many system processes establish connections to domain controllers. For more information about this topic, click the following article number to view the article in the Microsoft Knowledge Base:183366 WNetAddConnection2 and multiple user credentials
- If the Guest account is enabled on the destination computer, it is possible to pass both an invalid username and password and to create a connection.
- The system does not reference count connections, thus, if any process, including your Active Directory Service Interfaces client process, deletes the connection then all processes using that connection have to be written to re-establish it when they find it has been deleted.
The Active Directory Service Interfaces OpenDsObject method uses the credentials of the logged on user to access IIS. The user name and the password that are given as parameters are ignored. You receive the following error message:
It also works if you use the following script code.
Set objLogon = CreateObject("LoginAdmin.ImpersonateUser")
objLogon.Logon "Administrator", "AdminPassword", "Machinename"
Set oNS = GetObject("IIS:")
Set oRoot = oNS.OpenDSObject("IIS://SERVER/SHARE", "Mordor\administrator", "Gollum", 1)
'User credentials are ignored
Set objLogon = Nothing
ID d'article : 218497 - Dernière mise à jour : 18 juin 2008 - Révision : 1