Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binding with LDAP issue

Status
Not open for further replies.

JesperDB

IS-IT--Management
Mar 29, 2010
3
0
0
DK
Hello everyone!

First of all, im new to VBS.

I fell over a script by MisterNiceGuy on this forum that fulfilled my search for a script that allow users to change their password, having to know their old password, in my scenario it would've been used by my users when they were about to login through a web based captive portal for the first time, as the captive portal does'nt support the "change password at next login" when users are created in AD.

But i have an issue with the script, i want to be able to run it from the users pc's, that arent members of the domain, but on the same network.

It works flawlessly on the server.

Code:
'Script Starts Here.
Dim User, Username, Domain, InitialMsg, SecondMsg

'Bind to Active Directory System Info
Set AdsSysteminfo = CreateObject("adsysteminfo")
UserDomain=AdsSystemInfo.DomainShortName

'InitialMsg="Please enter the username that needs the password changed!"
'SecondMsg="Sorry, but you must enter a username to continue!" &vbCr &"Or press Cancel to quit." &vbCr
'UserName=GetPassword(InitialMsg)
AskUser

Sub AskUser
On Error Resume Next
Set User=GetObject("WinNT://" &Userdomain &"/" &Username & ",user")
If err.number<>0 Then
InitialMsg="Please enter a valid username that needs the password changed!"
SecondMsg="Sorry, but you must enter a username to continue!" &vbCr &"Or press Cancel to quit." &vbCr
UserName=GetPassword(InitialMsg)
AskUser
wscript.quit
End If
InitialMsg=UserName &Vbcr &"Please enter your current password"
SecondMsg="Sorry you must enter a password." &vbCr &"Or press Cancel to quit." &vbCr
OldPassword=GetPassword(InitialMsg)

InitialMsg=UserName &Vbcr &"Please enter your new password"
NewPassword1=GetPassword(InitialMsg)

InitialMsg=UserName &Vbcr &"Please verify the new password"
NewPassword2=GetPassword(InitialMsg)

If NewPassword1=NewPassword2 Then
Call User.ChangePassword(OldPassword,NewPassword1)
Select Case Err.number
case 0
msgbox "Password Changed Successfully"
wscript.quit
Case -2147024810
msgbox "Password Not Changed!" &vbCr &" An error occurred, Please try again." &vbCr &"The specific error number is:" & err.number _
&Vbcr &"The error message is: The specified network password is not correct."
Case -2147022651
msgbox "Password Not Changed!" &vbCr &"An Error occurred, Please try again." &vbCr &"The specific Error number Is:" & err.number _
&Vbcr &"The error message is: The password does not meet the password policy requirements. Check the minimum password length, " _
& "password complexity and password history requirements."
Case Else
msgbox "Password Not Changed!" &vbCr &" An error occurred, Please try again." &vbCr &"The specific error number is:" & err.number _
& "A specific error message is not available."
End Select
err.clear
AskUser
Else
Msgbox "Sorry, the new password entries do not match!" &vbCr &"Please try again"
AskUser
End If
End Sub


Function Getpassword(ask)

getpassword= InputBOx(ask,"Password entry form")
If getpassword = vbEmpty Then WScript.Quit
If getpassword = "" Then getpassword=GetPassword(SecondMSg &initialmsg)

end function

What do i need to change here? I'm lost :)

Best Regards

Jesper
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top