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!

ADSI usr.ChangePassword error

Status
Not open for further replies.

tklear

Programmer
Jan 16, 2003
37
0
0
US
I'm using the ASP script below to change a user's password by calling ADSI. This works fine as long as the user follows all the enforced rules for password creation. If they don't I get a very general error that I'm displaying with err.description. The error states:

450, Microsoft VBScript runtime error, , Wrong number of arguments or invalid property assignment

It occurred because I entered a password I used previously.

How can I get a more specific error to display for the user?

Thanks.

Code:

Set usr = GetObject("WinNT://rockit/" & ltrim(rtrim(Request.Form("usr"))) & ",user")
usr.ChangePassword (Request.Form("OLDpw"), Request.Form("NEWpw"))

If Err <> 0 Then
PassOK = 0
Response.Write &quot;Error occurred &quot; & Err.number, Err.Description, err.Source, err.helpfile & &quot;<P>&quot;
Else
Response.Write &quot;Password successfully changed&quot;
PassOK = 1
End If

set usr = nothing

If PassOK = 0 Then Response.Write &quot;An Error Occurred. Password Not Updated.<br>&quot; & Err.number & &quot;, &quot; & Err.Source & &quot;, &quot; & err.helpfile & &quot;, &quot; & Err.Description
 
Well since i have no ActiveDirectory here to test, also i've checked all my sources and i dont see any other way of doing this(All microsoft examples has some of the &quot;On Error Resume Next&quot;). I see no way of knwing the password to an user so you cannot loop throu all the users andm check that against.

Code:
'turn on error handling
On Error Resume Next
if Request.Form(&quot;OLDpw&quot;)<>&quot;&quot; and Request.Form(&quot;NEWpw&quot;)<>&quot;&quot; then
   Set usr = GetObject(&quot;WinNT://rockit/&quot; & ltrim(rtrim(Request.Form(&quot;usr&quot;))) & &quot;,user&quot;)
   usr.ChangePassword (Request.Form(&quot;OLDpw&quot;), Request.Form(&quot;NEWpw&quot;))
end if
If Err <> 0 Then
   Response.Write &quot;An Error Occurred.  Password Not Updated.&quot;
Else
       Response.Write &quot;Password successfully changed&quot;
End If
set usr = nothing
'turning off error handling
On Error Resume 0
  

________
George, M
 
Thanks for trying but this is basically what I've already tried except to add:
On Error Resume 0
at the end to turn off error trapping.

The result is the same. Regardless of why the password can't be updated the error is trapped but no information is provided as to the reason.

I can give a friendly error message stating that the password was not changed but I can't tell the user which one of the Active Directory password rules they did not fulfill.

Most of the rules I can check but without being able to pull password history I can't check whether they tried to reuse a previous password. Plus if the rules being enforced are changed, the coded error checking will have to be updated. I hate to go this route if I can help it. Anyway, I'll keep looking.
Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top