I am trying to write a script to set a user password and the script must be run from a machine that is not a domain member.
Background:
We are migrating to Exchange from Groupwise in 12 days. We still have a ton of
machines that are not part of AD, still in NDS. Users all have accounts and
mailboxes in AD. Many Novell users have not logged into AD. During our
migration we would like the techs to quickly reset user passwords for those
that do not know their AD passwords. Techs will be in the field at distributed
locations to help with outlook connectivity. They will not know the existing
password.
When i run this from a non domain member I get "The specified domain either
does not exist or could not be contacted". It runs fine from a domain member
Here is the code - thanks to anyone that can help.
'Set a Users password
'Written by: Shawn Hayes
'Date: 8-31-05
'Variables
Dim strUserName, strUserDN, strDNSDomain, strNetBiosDomain, strpassword,
strpassword1, strpassword2
Dim strUserName1, strUserName2, strmsgresult, strcontinue, stradminID,
stradminpwd, stradminpwd1, stradminpwd2
strNetBiosDomain = "ourdomainname\"
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1
Const ADS_PROPERTY_CLEAR = 1
Const ADS_SECURE_AUTHENTICATION = 1
'Input box prompts for UserID
msgbox ("You must enter a userid with privledges in AD to change user
passwords!")
stradminID = InputBox ("Enter Your Admin account name used to connect to
AD", "Enter Your Admin account name used to connect to AD", "")
'Input box prompts for admins password
Do
stradminpwd1 = InputBox ("Enter the Admin Password", " Admin Password", "")
stradminpwd2 = InputBox ("Reenter the Admin password", "Admin Password", "")
If stradminpwd1 <> stradminpwd2 then
msgbox ("Admin Passwords do not match")
strpassword = "nothing"
Else
strpassword = "equal"
End IF
Loop until strpassword = "equal"
strpassword = "nothing"
'User information
Do
'Input box prompts for UserID
strUsername1 = InputBox ("Enter the Active Directory UserID", "Enter the
Users Active Directory UserID", "")
'Input box prompts for users new password
Do
strPassword1 = InputBox ("Enter the new Password", "Password", "")
strPassword2 = InputBox ("Reenter the password", "Password", "")
If strpassword1 <> strpassword2 then
msgbox ("Passwords do not match")
strpassword = "nothing"
Else
strpassword = "equal"
End IF
Loop until strpassword = "equal"
Set objNetwork = CreateObject("Wscript.Network")
'Connect to RootDSE
'Set objRoot = GetObject("LDAP://domaincontroller.ourdomain.com/RootDSE")
'Set objroot = GetObject("LDAP:")
'Set objDomain = objRoot.OpenDSObject("LDAP://cn=domain controller,OU=domain
controllers,dc=ourdomain,dc=com", strNetBiosDomain & stradminID, stradminpwd1,
ADS_SECURE_AUTHENTICATION)
'Set objDomain = objRoot.OpenDSObject("LDAP://dc=ourdomain,dc=com",
strNetBiosDomain & stradminID, stradminpwd1, ADS_SECURE_AUTHENTICATION)
'strDNSDomain = objRootDSE.Get("defaultNamingContext")
'strDNSDomain = objdomain.Get("defaultNamingContext")
'Determine UsersDN from netbios name
Set objTrans = CreateObject("NameTranslate")
objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & strUserName1
strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)
strmsgresult = msgbox ("OK to change this user's password? " & struserdn,
vbyesno)
'msgbox (strmsgresult)
If strmsgresult = "6" then
'Set the Users Password
'Set objUser = GetObject ("LDAP://" & strUserDN)
Set ObjDomain = GetObject ("LDAP:")
Set objuser =
ObjDomain.OpenDSObject("LDAP://domaincontroller.ourdomain.com/" & strUserDN,
strNetBiosDomain & stradminID, stradminpwd1, ADS_SECURE_AUTHENTICATION)
objUser.SetPassword strpassword1
Msgbox ("Password Set!")
wscript.quit
Else
strcontinue = Msgbox ("Password not set, would you like to reenter the
UserID?", vbyesno)
If strcontinue <> "6" then
wscript.quit
End IF
End IF
Loop
|
I am trying to write a script to set a user password and the script must be
run from a machine that is not a domain member.
Background:
We are migrating to Exchange from Groupwise in 12 days. We still have
a ton of machines that are not part of AD, still in NDS. Users all have
accounts and mailboxes in AD. Many Novell users have not logged into
AD. During our migration we would like the techs to quickly reset
user passwords for those that do not know their AD passwords. Techs will
be in the field at distributed locations to help with outlook
connectivity. They will not know the existing password.
When i run this from a non domain member I get "The specified domain either
does not exist or could not be contacted". It runs fine from a domain
member
Here is the code - thanks to anyone that can help.
'Set a Users password
'Written by: Shawn Hayes 'Date: 8-31-05 'Variables
Dim strUserName, strUserDN, strDNSDomain, strNetBiosDomain, strpassword, strpassword1, strpassword2 Dim strUserName1, strUserName2, strmsgresult, strcontinue, stradminID, stradminpwd, stradminpwd1, stradminpwd2 strNetBiosDomain = "ourdomainname\" Const ADS_NAME_INITTYPE_GC = 3 Const ADS_NAME_TYPE_NT4 = 3 Const ADS_NAME_TYPE_1779 = 1 Const ADS_PROPERTY_CLEAR = 1 Const ADS_SECURE_AUTHENTICATION = 1 'Input box prompts for UserID
msgbox ("You must enter a userid with privledges in AD to change user passwords!") stradminID = InputBox ("Enter Your Admin account name used to connect to AD", "Enter Your Admin account name used to connect to AD", "") 'Input box prompts for admins password Do stradminpwd1 = InputBox ("Enter the Admin Password", " Admin Password", "") stradminpwd2 = InputBox ("Reenter the Admin password", "Admin Password", "") If stradminpwd1 <> stradminpwd2 then msgbox ("Admin Passwords do not match") strpassword = "nothing" Else strpassword = "equal" End IF Loop until strpassword = "equal" strpassword = "nothing"
'User information
Do 'Input box prompts for UserID strUsername1 = InputBox ("Enter the Active Directory UserID", "Enter the Users Active Directory UserID", "") 'Input box prompts for users new password Do strPassword1 = InputBox ("Enter the new Password", "Password", "") strPassword2 = InputBox ("Reenter the password", "Password", "") If strpassword1 <> strpassword2 then msgbox ("Passwords do not match") strpassword = "nothing" Else strpassword = "equal" End IF Loop until strpassword = "equal" Set objNetwork = CreateObject("Wscript.Network") 'Connect to RootDSE 'Set objRoot = GetObject("LDAP://domaincontroller.ourdomain.com/RootDSE") 'Set objroot = GetObject("LDAP:") 'Set objDomain = objRoot.OpenDSObject("LDAP://cn=domain controller,OU=domain controllers,dc=ourdomain,dc=com", strNetBiosDomain & stradminID, stradminpwd1, ADS_SECURE_AUTHENTICATION) 'Set objDomain = objRoot.OpenDSObject("LDAP://dc=ourdomain,dc=com", strNetBiosDomain & stradminID, stradminpwd1, ADS_SECURE_AUTHENTICATION) 'strDNSDomain = objRootDSE.Get("defaultNamingContext") 'strDNSDomain = objdomain.Get("defaultNamingContext") 'Determine UsersDN from netbios name Set objTrans = CreateObject("NameTranslate") objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & strUserName1 strUserDN = objTrans.Get(ADS_NAME_TYPE_1779) strmsgresult = msgbox ("OK to change this user's password? " & struserdn, vbyesno) 'msgbox (strmsgresult) If strmsgresult = "6" then 'Set the Users Password 'Set objUser = GetObject ("LDAP://" & strUserDN) Set ObjDomain = GetObject ("LDAP:") Set objuser = ObjDomain.OpenDSObject("LDAP://domaincontroller.ourdomain.com/" & strUserDN, strNetBiosDomain & stradminID, stradminpwd1, ADS_SECURE_AUTHENTICATION) objUser.SetPassword strpassword1 Msgbox ("Password Set!") wscript.quit Else strcontinue = Msgbox ("Password not set, would you like to reenter the UserID?", vbyesno) If strcontinue <> "6" then wscript.quit End IF End IF Loop |
