hi
This is how I Achieved...
<%
on error resume next
Dim UserName
UserName=Request.ServerVariables ("LOGON_USER")
UserName=Split(UserName,"\")
strUserCN = Trim(UserName(1))
response.write("You are logged in as:
"&strUserCN)
strOldPassword = request.form("oldpass")
strNewPassword = request.form("newpass")
strPassVerify = request.form("passverify")
if strOldPassword="" then
response.write "<br>Change
Password<br><br>"
response.write "<hr><form method=post
action=chngpwd.asp><table>"
' response.write "<tr><td>User Name:
</td><td><input type=text
name=cn></td><tr>"
response.write "<tr><td>Old Password:
</td><td><input type=password
name=oldpass></td></tr>"
response.write "<tr><td>New Password:
</td><td><input type=password
name=newpass></td></tr>"
response.write "<tr><td>Verify
Password: </td><td><input
type=password
name=passverify></td></tr>"
response.write "<tr
height='10'><td></td><td >
</td></tr>"
response.write
"<tr><td> </td><td
><input type=submit
value='Reset Password'> <input
type=reset
value='Reset'></td></tr>"
response.write "</table>"
response.end
else
if strNewPassword = strPassVerify then
Dim Conn, strRS, RS, strConn
Set Conn =
Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.Recordset")
Conn.Provider = "ADSDSOObject"
strConn = "Active Directory Provider"
Conn.Open strConn
SamName=strUserCN
strQuery = "Select AdsPath, CN From 'LDAP://domain'
Where
objectClass='user' And sAMAccountName='" &
SamName & "'"
RS.Open strQuery, Conn,1,1
'Response.Write "Name:
"&RS(0)&"<br>Path:
"&RS(1)&"<br><br>"
set usr = GetObject(RS(1))
usr.ChangePassword strOldPassword,strNewPassword
usr.SetInfo
RS.close
Conn.close
else
response.write
"<hr><br><br>"
response.write "The password and confirmation do
not match. <a
href='JavaScript:history.go(-1);' class='link'
><b>Click here to try"
_
& "again...</b></a>"
response.end
end if
end if
If Err Then
AdsiErr()
Else
Response.Write "<br>Your password was
changed successfully <a
href='default.aspx' class='link'
><b>Back</b></a>"
Response.end
End If
Sub AdsiErr()
Dim e
e = Err.Number
h = Hex(e)
If h = "80005000" Then
Response.write "An invalid ADSI
pathname was passed. "
Elseif h = "1A8" Then
ServerName =
Request.ServerVariables("SERVER_NAME")
Response.write "<font color=red><b>The web
server " & ServerName & "
does not have permission to change passwords using HTML
mode." _
& "In order to be granted this permission, the web
server must be a
domain" _
& "controller in the " & domain &
" domain or this .asp script must be
served" _
& "by a domain admin account instead of the
IUSR_<I>MachineName</I>account.</b></fo
nt>"
Response.Write "<br><br><a
href='JavaScript:history.go(-1);'
class='link' ><b>Click here to try" _
&
"again...</b></a></font>"
Elseif h = "800041E4" Then
Response.write "<font
color=red><b>Username not found."
Response.Write "<br><br><a
href='JavaScript:history.go(-1);'><b>Click
here to try" _
&
"again...</b></a></font>"
Elseif h = "8007052F" Then
Response.write "<font color=red><b>Your
password could not" _
& "be changed. Each password must be used for at
least x
days.</A></b></font>"
Response.Write "<br><br><a
href='/chngpwd.asp'><b>Click here to go " _
& "back to the login
page...</b></a></font>"
Elseif h = "80070056" Then
Response.write "<font color=red><b>The
username or old" _
& "password is incorrect. <P> <A
HREF=chngpwd.asp?username=" & user
&">Please" _
& "try
again.</A></b></font>"
Elseif h = "800708C5" Then
Response.write "<font color=red><b>The new
password does not" _
& "meet the password policies. The password may be
too short or you
have" _
& "already used this password recently. <P>
<A
HREF=chngpwd.asp?username="& user &
">Please try
again.</A></b></font>"
Else
Response.write "<font color=red><b>Unable
to changepassword. Debugging
information:<P>"
Response.write "Unexpected Error " & e &
" (" & Hex(e) & ")"
Response.Write "<br><br><a
href='JavaScript:history.go(-1);'><b>Click
here to try " _
&
"again...</b></a></b></font>&
quot;
End If
End Sub
%>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharp googlegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribe googlegroups.com
For more options, visit this group at http://groups.
google.com/group/C_Sharp
-~----------~----~----~----~------~----~------~--~---
|