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>&nbsp;</DIV>
<DIV>strNetbiosdomain is a variable I set</DIV>
<DIV>&nbsp;</DIV>
<DIV>script dies before line 61</DIV>
<DIV>&nbsp;</DIV>
<DIV>A web front-end is where we were leaning.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Shawn<BR><BR>&gt;&gt;&gt; "Al Mulnick" &lt;[EMAIL PROTECTED]&gt; 08/31/05 
03:19PM &gt;&gt;&gt;<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?&nbsp; 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.&nbsp; We still have a ton of machines that are not part of AD, still in 
NDS.&nbsp; Users all have accounts and mailboxes in AD.&nbsp; Many Novell users 
have not logged into AD.&nbsp; During our migration we would like the techs to 
quickly reset user passwords for those that do not know their AD 
passwords.&nbsp; Techs will be in the field at distributed locations to help 
with outlook connectivity.&nbsp; 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".&nbsp; 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>&nbsp; 'Input box prompts for 
UserID<BR>&nbsp;&nbsp;&nbsp; msgbox ("You must enter a userid with privledges 
in 
AD to change user passwords!")<BR>&nbsp;&nbsp;&nbsp; stradminID = InputBox 
("Enter Your Admin account name used to connect to AD", "Enter Your Admin 
account name used to connect to AD", "")<BR>&nbsp; 'Input box prompts for 
admins 
password<BR>&nbsp; Do<BR>&nbsp;&nbsp;&nbsp; stradminpwd1 = InputBox ("Enter the 
Admin Password", " Admin Password", "")<BR>&nbsp;&nbsp;&nbsp; stradminpwd2 = 
InputBox ("Reenter the Admin password", "Admin Password", 
"")<BR>&nbsp;&nbsp;&nbsp; If stradminpwd1 &lt;&gt; stradminpwd2 
then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msgbox ("Admin Passwords do not 
match")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strpassword = 
"nothing"<BR>&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
strpassword = "equal"<BR>&nbsp;&nbsp;&nbsp; End IF<BR>&nbsp; Loop until 
strpassword = "equal"<BR><BR>strpassword = "nothing"<BR><BR>'User 
information<BR>Do<BR>&nbsp; 'Input box prompts for UserID<BR>&nbsp;&nbsp;&nbsp; 
strUsername1 = InputBox ("Enter the Active Directory UserID", "Enter the Users 
Active Directory UserID", "")<BR>&nbsp; 'Input box prompts for users new 
password<BR>&nbsp; Do<BR>&nbsp;&nbsp;&nbsp; strPassword1 = InputBox ("Enter the 
new Password", "Password", "")<BR>&nbsp;&nbsp;&nbsp; strPassword2 = InputBox 
("Reenter the password", "Password", "")<BR>&nbsp;&nbsp;&nbsp; If strpassword1 
&lt;&gt; strpassword2 then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msgbox ("Passwords 
do not match")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strpassword = 
"nothing"<BR>&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
strpassword = "equal"<BR>&nbsp;&nbsp;&nbsp; End IF<BR>&nbsp; Loop until 
strpassword = "equal"<BR><BR>&nbsp; Set objNetwork = 
CreateObject("Wscript.Network")<BR><BR>&nbsp; 'Connect to RootDSE<BR>&nbsp; 
'Set 
objRoot = GetObject("LDAP://domaincontroller.ourdomain.com/RootDSE")<BR>&nbsp; 
'Set objroot = GetObject("LDAP:")<BR>&nbsp; 'Set objDomain = 
objRoot.OpenDSObject("LDAP://cn=domain controller,OU=domain 
controllers,dc=ourdomain,dc=com", strNetBiosDomain &amp; stradminID, 
stradminpwd1, ADS_SECURE_AUTHENTICATION)<BR>&nbsp; 'Set objDomain = 
objRoot.OpenDSObject("LDAP://dc=ourdomain,dc=com", strNetBiosDomain &amp; 
stradminID, stradminpwd1, ADS_SECURE_AUTHENTICATION)<BR>&nbsp; 'strDNSDomain = 
objRootDSE.Get("defaultNamingContext")<BR>&nbsp; 'strDNSDomain = 
objdomain.Get("defaultNamingContext")<BR><BR>&nbsp; 'Determine UsersDN from 
netbios name<BR>&nbsp; Set objTrans = CreateObject("NameTranslate")<BR>&nbsp; 
objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain &amp; strUserName1<BR>&nbsp; 
strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)<BR>&nbsp; strmsgresult = msgbox 
("OK to change this user's password? " &amp; struserdn, vbyesno)<BR>&nbsp; 
'msgbox (strmsgresult)<BR>&nbsp; If strmsgresult = "6" 
then<BR>&nbsp;&nbsp;&nbsp; 'Set the Users Password<BR>&nbsp;&nbsp;&nbsp; 'Set 
objUser = GetObject ("LDAP://" &amp; strUserDN)<BR>&nbsp;&nbsp;&nbsp; Set 
ObjDomain = GetObject ("LDAP:")<BR>&nbsp;&nbsp;&nbsp; Set objuser = 
ObjDomain.OpenDSObject("LDAP://domaincontroller.ourdomain.com/" &amp; 
strUserDN, 
strNetBiosDomain &amp; stradminID, stradminpwd1, 
ADS_SECURE_AUTHENTICATION)<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp; objUser.SetPassword strpassword1<BR>&nbsp;&nbsp;&nbsp; 
Msgbox ("Password Set!")<BR>&nbsp;&nbsp;&nbsp; wscript.quit<BR>&nbsp; 
Else<BR>&nbsp;&nbsp;&nbsp; strcontinue = Msgbox ("Password not set, would you 
like to reenter the UserID?", vbyesno)<BR>&nbsp;&nbsp;&nbsp; If strcontinue 
&lt;&gt; "6" then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
wscript.quit<BR>&nbsp;&nbsp;&nbsp; End IF<BR>&nbsp; End 
IF<BR>Loop<BR><BR><BR></DIV></BODY></HTML>

Reply via email to