Thanks for the reply Al. strNetbiosdomain is a variable I set
script dies before line 61 A web front-end is where we were leaning. Shawn >>> "Al Mulnick" <[EMAIL PROTECTED]> 08/31/05 03:19PM >>> How does the non-domain member find strNetBIOSDomain ? On line 61, how about having it echo to the user what the strNetBIOSDomain and strUserName1 variables result in? Does it match what you think it should be? Is it possible to find that information from the workstation it's running on? Any reason you wouldn't run this as a web page from a domain member instead? Al ________________________________ From: [EMAIL PROTECTED] on behalf of Shawn Hayes Sent: Wed 8/31/2005 2:26 PM To: [email protected] Subject: [ActiveDir] VBscript to set a password for a user in AD but ran from a non domain member 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> <META content="MSHTML 7.00.5112.0" name=GENERATOR></HEAD> <BODY style="MARGIN-TOP: 2px; FONT: 10pt Tahoma; MARGIN-LEFT: 2px"> <DIV>Thanks for the reply Al.</DIV> <DIV> </DIV> <DIV>strNetbiosdomain is a variable I set</DIV> <DIV> </DIV> <DIV>script dies before line 61</DIV> <DIV> </DIV> <DIV>A web front-end is where we were leaning.</DIV> <DIV> </DIV> <DIV>Shawn<BR><BR>>>> "Al Mulnick" <[EMAIL PROTECTED]> 08/31/05 03:19PM >>><BR>How does the non-domain member find strNetBIOSDomain ?<BR><BR>On line 61, how about having it echo to the user what the strNetBIOSDomain and strUserName1 variables result in?<BR><BR>Does it match what you think it should be? Is it possible to find that information from the workstation it's running on? Any reason you wouldn't run this as a web page from a domain member instead? <BR><BR>Al<BR><BR>________________________________<BR><BR>From: [EMAIL PROTECTED] on behalf of Shawn Hayes<BR>Sent: Wed 8/31/2005 2:26 PM<BR>To: [email protected]<BR>Subject: [ActiveDir] VBscript to set a password for a user in AD but ran from a non domain member<BR><BR><BR><BR>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.<BR><BR>Background:<BR>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.<BR><BR>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<BR><BR>Here is the code - thanks to anyone that can help.<BR><BR>'Set a Users password<BR>'Written by: Shawn Hayes<BR>'Date: 8-31-05<BR><BR>'Variables<BR>Dim strUserName, strUserDN, strDNSDomain, strNetBiosDomain, strpassword, strpassword1, strpassword2<BR>Dim strUserName1, strUserName2, strmsgresult, strcontinue, stradminID, stradminpwd, stradminpwd1, stradminpwd2<BR>strNetBiosDomain = "ourdomainname\"<BR>Const ADS_NAME_INITTYPE_GC = 3<BR>Const ADS_NAME_TYPE_NT4 = 3<BR>Const ADS_NAME_TYPE_1779 = 1<BR>Const ADS_PROPERTY_CLEAR = 1<BR>Const ADS_SECURE_AUTHENTICATION = 1<BR><BR> 'Input box prompts for UserID<BR> msgbox ("You must enter a userid with privledges in AD to change user passwords!")<BR> stradminID = InputBox ("Enter Your Admin account name used to connect to AD", "Enter Your Admin account name used to connect to AD", "")<BR> 'Input box prompts for admins password<BR> Do<BR> stradminpwd1 = InputBox ("Enter the Admin Password", " Admin Password", "")<BR> stradminpwd2 = InputBox ("Reenter the Admin password", "Admin Password", "")<BR> If stradminpwd1 <> stradminpwd2 then<BR> msgbox ("Admin Passwords do not match")<BR> strpassword = "nothing"<BR> Else<BR> strpassword = "equal"<BR> End IF<BR> Loop until strpassword = "equal"<BR><BR>strpassword = "nothing"<BR><BR>'User information<BR>Do<BR> 'Input box prompts for UserID<BR> strUsername1 = InputBox ("Enter the Active Directory UserID", "Enter the Users Active Directory UserID", "")<BR> 'Input box prompts for users new password<BR> Do<BR> strPassword1 = InputBox ("Enter the new Password", "Password", "")<BR> strPassword2 = InputBox ("Reenter the password", "Password", "")<BR> If strpassword1 <> strpassword2 then<BR> msgbox ("Passwords do not match")<BR> strpassword = "nothing"<BR> Else<BR> strpassword = "equal"<BR> End IF<BR> Loop until strpassword = "equal"<BR><BR> Set objNetwork = CreateObject("Wscript.Network")<BR><BR> 'Connect to RootDSE<BR> 'Set objRoot = GetObject("LDAP://domaincontroller.ourdomain.com/RootDSE")<BR> 'Set objroot = GetObject("LDAP:")<BR> 'Set objDomain = objRoot.OpenDSObject("LDAP://cn=domain controller,OU=domain controllers,dc=ourdomain,dc=com", strNetBiosDomain & stradminID, stradminpwd1, ADS_SECURE_AUTHENTICATION)<BR> 'Set objDomain = objRoot.OpenDSObject("LDAP://dc=ourdomain,dc=com", strNetBiosDomain & stradminID, stradminpwd1, ADS_SECURE_AUTHENTICATION)<BR> 'strDNSDomain = objRootDSE.Get("defaultNamingContext")<BR> 'strDNSDomain = objdomain.Get("defaultNamingContext")<BR><BR> 'Determine UsersDN from netbios name<BR> Set objTrans = CreateObject("NameTranslate")<BR> objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & strUserName1<BR> strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)<BR> strmsgresult = msgbox ("OK to change this user's password? " & struserdn, vbyesno)<BR> 'msgbox (strmsgresult)<BR> If strmsgresult = "6" then<BR> 'Set the Users Password<BR> 'Set objUser = GetObject ("LDAP://" & strUserDN)<BR> Set ObjDomain = GetObject ("LDAP:")<BR> Set objuser = ObjDomain.OpenDSObject("LDAP://domaincontroller.ourdomain.com/" & strUserDN, strNetBiosDomain & stradminID, stradminpwd1, ADS_SECURE_AUTHENTICATION)<BR> <BR> <BR> objUser.SetPassword strpassword1<BR> Msgbox ("Password Set!")<BR> wscript.quit<BR> Else<BR> strcontinue = Msgbox ("Password not set, would you like to reenter the UserID?", vbyesno)<BR> If strcontinue <> "6" then<BR> wscript.quit<BR> End IF<BR> End IF<BR>Loop<BR><BR><BR></DIV></BODY></HTML>
