My code is below. I am trying to create an LDAP account using a local user (specifically so it can be used by my web server's IUSR account). We have two domain controllers with "A" records (ldap.mydomain.dom) for both. That way we have failover if one server is not accessable. I put the dns record to my domain server into my ldap string. My thought is that this should work fine, since it will just go look up the dns record get the server and then use the server's IP address. However I keep getting an error on the password line. It creates the accoutn just fine, but the password line fails. So, I have an account without a password. If I just put one of the domain controller names or IP addresses in it works fine, but with the dns record I get this error ...
I think my syntax is fine, because it works perfectly with the domain controller's name or IP. I guess I'm just wondering if anyone has any ideas why putting the dns record in is causing it to fail. I'd rather not put the machine name in because then we have no failover, and if we ever change the name of the domain controller I'd have to go adjust all my scripts again. Thanks for any help.
Also one bit of info ... the code is being deployed into a DMZ on a different domain than the one being accessed hence the need for being pointed to a specific server.
Error: One or more input parameters are invalid
Code: 80070034
Source: Active Directory
I think my syntax is fine, because it works perfectly with the domain controller's name or IP. I guess I'm just wondering if anyone has any ideas why putting the dns record in is causing it to fail. I'd rather not put the machine name in because then we have no failover, and if we ever change the name of the domain controller I'd have to go adjust all my scripts again. Thanks for any help.
Also one bit of info ... the code is being deployed into a DMZ on a different domain than the one being accessed hence the need for being pointed to a specific server.
Code:
strUsername = "mydomain\myuser"
strPassword = "password"
Set objLDAP = GetObject("LDAP:")
Set objContainer = objLDAP.OpenDSObject("LDAP://ldap.mydomain.dom/ou=test,dc=mydomain,dc=dom", strUsername, strPassword, 0)
Set objUser = objContainer.Create("user", "cn=Fred Clown")
objUser.sAMAccountName = "fredclown"
objUser.SetInfo
objUser.SetPassword "Freddy1234" '<---- This is the error line
objUser.AccountDisabled = False
objUser.employeeID = "P000000000"
objUser.displayName = "Fred Clown"
objUser.givenName = "Fred"
objUser.initials = "T"
objUser.sn = "Clown"
objUser.userAccountControl = "66048"
objUser.SetInfo
Set objUser = Nothing
Set objContainer = Nothing
Set objLDAP = Nothing