Hi, I'm having problems writing a password change script.

I want to give my users the ability to change their AD domain password via
a local script.

I also want the user to just put in their sAMAccountName and NOT their dn in
the input box for user name.
I think i have to use the WinNt provider for that and not LDAP.

Finally, i guess i have to use IE to mask the password as they are typing it.
Thanks.

P.S- is there anyway to have the script send an email via CDO if it fails
and an clear error message as to why or is this not feasible on many local
machines?

Thanks again!!

RE: password changer by ESP

ESP
Thu Dec 01 15:29:21 CST 2005

This should get ya started.

'Password Changing:
http://www.microsoft.com/technet/scriptcenter/scripts/ad/users/pwds/default.mspx

'Password Masking:
http://www.microsoft.com/technet/scriptcenter/scripts/misc/password/default.mspx

'Code for samAccountName entry:
Const ADS_SCOPE_SUBTREE = 2
strUserID = InputBox("Enter the machine name without '\\' ", "Machine Name")
If strUserID = "" Then WScript.Quit
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT sAMAccountName FROM 'LDAP://dc=YourDomain,dc=com' WHERE
objectCategory='user' " & _
"AND sAMAccountName='" & strUserID & "'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo objRecordSet.Fields("sAMAccountName").Value
objRecordSet.MoveNext
Loop


ESP






"tkern" wrote:

> Hi, I'm having problems writing a password change script.
>
> I want to give my users the ability to change their AD domain password via
> a local script.
>
> I also want the user to just put in their sAMAccountName and NOT their dn in
> the input box for user name.
> I think i have to use the WinNt provider for that and not LDAP.
>
> Finally, i guess i have to use IE to mask the password as they are typing it.
> Thanks.
>
> P.S- is there anyway to have the script send an email via CDO if it fails
> and an clear error message as to why or is this not feasible on many local
> machines?
>
> Thanks again!!
>

RE: password changer by tkern

tkern
Thu Dec 01 15:47:03 CST 2005

When i run the code from the second link you gave me for masking passwords
via IE, i always get the error- "Object doesn't support this property or
method: 'objExplorer.Document.Body.All.OKClicked'"

Thanks

"ESP" wrote:

> This should get ya started.
>
> 'Password Changing:
> http://www.microsoft.com/technet/scriptcenter/scripts/ad/users/pwds/default.mspx
>
> 'Password Masking:
> http://www.microsoft.com/technet/scriptcenter/scripts/misc/password/default.mspx
>
> 'Code for samAccountName entry:
> Const ADS_SCOPE_SUBTREE = 2
> strUserID = InputBox("Enter the machine name without '\\' ", "Machine Name")
> If strUserID = "" Then WScript.Quit
> Set objConnection = CreateObject("ADODB.Connection")
> Set objCommand = CreateObject("ADODB.Command")
> objConnection.Provider = "ADsDSOObject"
> objConnection.Open "Active Directory Provider"
> Set objCommand.ActiveConnection = objConnection
> objCommand.Properties("Page Size") = 1000
> objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
> objCommand.CommandText = _
> "SELECT sAMAccountName FROM 'LDAP://dc=YourDomain,dc=com' WHERE
> objectCategory='user' " & _
> "AND sAMAccountName='" & strUserID & "'"
> Set objRecordSet = objCommand.Execute
> objRecordSet.MoveFirst
> Do Until objRecordSet.EOF
> Wscript.Echo objRecordSet.Fields("sAMAccountName").Value
> objRecordSet.MoveNext
> Loop
>
>
> ESP
>
>
>
>
>
>
> "tkern" wrote:
>
> > Hi, I'm having problems writing a password change script.
> >
> > I want to give my users the ability to change their AD domain password via
> > a local script.
> >
> > I also want the user to just put in their sAMAccountName and NOT their dn in
> > the input box for user name.
> > I think i have to use the WinNt provider for that and not LDAP.
> >
> > Finally, i guess i have to use IE to mask the password as they are typing it.
> > Thanks.
> >
> > P.S- is there anyway to have the script send an email via CDO if it fails
> > and an clear error message as to why or is this not feasible on many local
> > machines?
> >
> > Thanks again!!
> >

RE: password changer by ESP

ESP
Thu Dec 01 15:54:02 CST 2005

Create a HTM file containing this code, and place it in the path the VBS is
calling.
objExplorer.Navigate "file:///c:\scripts\password.htm"

(Ex. c:\scripts\password.htm)


<SCRIPT LANGUAGE="VBScript">
Sub RunScript
OKClicked.Value = "OK"
End Sub
Sub CancelScript
OKClicked.Value = "Cancelled"
End Sub
</SCRIPT>
<BODY>
<font size="2" face="Arial">
Password: </font><font face="Arial">
<input type="password" name="UserPassword" size="40"></font></p>
<input type="hidden" name="OKClicked" size = "20">
<input id=runbutton class="button" type="button" value=" OK "
name="ok_button" onClick="RunScript">

<input id=runbutton class="button" type="button" value="Cancel"
name="cancel_button" onClick="CancelScript">
</BODY>


ESP




"tkern" wrote:

> When i run the code from the second link you gave me for masking passwords
> via IE, i always get the error- "Object doesn't support this property or
> method: 'objExplorer.Document.Body.All.OKClicked'"
>
> Thanks
>
> "ESP" wrote:
>
> > This should get ya started.
> >
> > 'Password Changing:
> > http://www.microsoft.com/technet/scriptcenter/scripts/ad/users/pwds/default.mspx
> >
> > 'Password Masking:
> > http://www.microsoft.com/technet/scriptcenter/scripts/misc/password/default.mspx
> >
> > 'Code for samAccountName entry:
> > Const ADS_SCOPE_SUBTREE = 2
> > strUserID = InputBox("Enter the machine name without '\\' ", "Machine Name")
> > If strUserID = "" Then WScript.Quit
> > Set objConnection = CreateObject("ADODB.Connection")
> > Set objCommand = CreateObject("ADODB.Command")
> > objConnection.Provider = "ADsDSOObject"
> > objConnection.Open "Active Directory Provider"
> > Set objCommand.ActiveConnection = objConnection
> > objCommand.Properties("Page Size") = 1000
> > objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
> > objCommand.CommandText = _
> > "SELECT sAMAccountName FROM 'LDAP://dc=YourDomain,dc=com' WHERE
> > objectCategory='user' " & _
> > "AND sAMAccountName='" & strUserID & "'"
> > Set objRecordSet = objCommand.Execute
> > objRecordSet.MoveFirst
> > Do Until objRecordSet.EOF
> > Wscript.Echo objRecordSet.Fields("sAMAccountName").Value
> > objRecordSet.MoveNext
> > Loop
> >
> >
> > ESP
> >
> >
> >
> >
> >
> >
> > "tkern" wrote:
> >
> > > Hi, I'm having problems writing a password change script.
> > >
> > > I want to give my users the ability to change their AD domain password via
> > > a local script.
> > >
> > > I also want the user to just put in their sAMAccountName and NOT their dn in
> > > the input box for user name.
> > > I think i have to use the WinNt provider for that and not LDAP.
> > >
> > > Finally, i guess i have to use IE to mask the password as they are typing it.
> > > Thanks.
> > >
> > > P.S- is there anyway to have the script send an email via CDO if it fails
> > > and an clear error message as to why or is this not feasible on many local
> > > machines?
> > >
> > > Thanks again!!
> > >

RE: password changer by tkern

tkern
Fri Dec 02 10:00:02 CST 2005

I still get the same error.
"Object doesn't support this property or
method:'objExplorer.Document.All.PasswordBox'"

I tried this on a Win XP sp2 and a win2k sp4 box with the same results.

Thanks

"ESP" wrote:

> Create a HTM file containing this code, and place it in the path the VBS is
> calling.
> objExplorer.Navigate "file:///c:\scripts\password.htm"
>
> (Ex. c:\scripts\password.htm)
>
>
> <SCRIPT LANGUAGE="VBScript">
> Sub RunScript
> OKClicked.Value = "OK"
> End Sub
> Sub CancelScript
> OKClicked.Value = "Cancelled"
> End Sub
> </SCRIPT>
> <BODY>
> <font size="2" face="Arial">
> Password: </font><font face="Arial">
> <input type="password" name="UserPassword" size="40"></font></p>
> <input type="hidden" name="OKClicked" size = "20">
> <input id=runbutton class="button" type="button" value=" OK "
> name="ok_button" onClick="RunScript">
>
> <input id=runbutton class="button" type="button" value="Cancel"
> name="cancel_button" onClick="CancelScript">
> </BODY>
>
>
> ESP
>
>
>
>
> "tkern" wrote:
>
> > When i run the code from the second link you gave me for masking passwords
> > via IE, i always get the error- "Object doesn't support this property or
> > method: 'objExplorer.Document.Body.All.OKClicked'"
> >
> > Thanks
> >
> > "ESP" wrote:
> >
> > > This should get ya started.
> > >
> > > 'Password Changing:
> > > http://www.microsoft.com/technet/scriptcenter/scripts/ad/users/pwds/default.mspx
> > >
> > > 'Password Masking:
> > > http://www.microsoft.com/technet/scriptcenter/scripts/misc/password/default.mspx
> > >
> > > 'Code for samAccountName entry:
> > > Const ADS_SCOPE_SUBTREE = 2
> > > strUserID = InputBox("Enter the machine name without '\\' ", "Machine Name")
> > > If strUserID = "" Then WScript.Quit
> > > Set objConnection = CreateObject("ADODB.Connection")
> > > Set objCommand = CreateObject("ADODB.Command")
> > > objConnection.Provider = "ADsDSOObject"
> > > objConnection.Open "Active Directory Provider"
> > > Set objCommand.ActiveConnection = objConnection
> > > objCommand.Properties("Page Size") = 1000
> > > objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
> > > objCommand.CommandText = _
> > > "SELECT sAMAccountName FROM 'LDAP://dc=YourDomain,dc=com' WHERE
> > > objectCategory='user' " & _
> > > "AND sAMAccountName='" & strUserID & "'"
> > > Set objRecordSet = objCommand.Execute
> > > objRecordSet.MoveFirst
> > > Do Until objRecordSet.EOF
> > > Wscript.Echo objRecordSet.Fields("sAMAccountName").Value
> > > objRecordSet.MoveNext
> > > Loop
> > >
> > >
> > > ESP
> > >
> > >
> > >
> > >
> > >
> > >
> > > "tkern" wrote:
> > >
> > > > Hi, I'm having problems writing a password change script.
> > > >
> > > > I want to give my users the ability to change their AD domain password via
> > > > a local script.
> > > >
> > > > I also want the user to just put in their sAMAccountName and NOT their dn in
> > > > the input box for user name.
> > > > I think i have to use the WinNt provider for that and not LDAP.
> > > >
> > > > Finally, i guess i have to use IE to mask the password as they are typing it.
> > > > Thanks.
> > > >
> > > > P.S- is there anyway to have the script send an email via CDO if it fails
> > > > and an clear error message as to why or is this not feasible on many local
> > > > machines?
> > > >
> > > > Thanks again!!
> > > >