Re: change password in active directory by webapplication (vb.net)

From: Joe Kaplan \(MVP - ADSI\) (joseph.e.kaplan_at_removethis.accenture.com)
Date: 04/26/04


Date: Sun, 25 Apr 2004 20:30:36 -0500

Hi,

Can you give details about what exception gets thrown? There are many
reasons why the SetPassword method might fail, including an inability to get
a secure connection to AD (SSL or Kerberos), a password policy issue or a
permissions issue.

I'd suggest using AuthenticationTypes.Secure and/or
AuthenticationTypes.SecureSocketsLayer on your initial bind.

Also, the Password property on the DirectoryEntry is not related to the
underlying password of a user object in Active Directory. That is the
password used to bind to the directory.

You may find lots of ideas on solving the problem by searching on
SetPassword. There are many threads on this in
microsoft.public.adsi.general.

Joe K.

"Sara" <raf60ir@aut.ac.ir> wrote in message
news:aeeb301.0404250716.7111e811@posting.google.com...
> Dear Sir,
> I want to change password of users in active directory by asp.net
> form.this is my code, but i recieve error could anyone help me to
> solve it. thanks
>
> Protected WithEvents newpass As System.Web.UI.WebControls.TextBox
> Protected WithEvents btn1 As System.Web.UI.WebControls.Button
> Protected WithEvents username As System.Web.UI.WebControls.TextBox
> Protected WithEvents oldpass As System.Web.UI.WebControls.TextBox
> Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles btn1.Click
> Dim dom As DirectoryEntry = New
> DirectoryEntry("LDAP://Hosnieh_Rafiee", "Hosnieh_Rafiee\admin11",
> "bbb")
>
> Dim entry As DirectoryEntry = New
> DirectoryEntry("LDAP://Hosnieh_Rafiee", username.Text, oldpass.Text)
> Dim search As New DirectorySearcher(entry)
>
> Dim result As SearchResult = search.FindOne
>
> 'If entry.Password = oldpass.Text Then
> Dim b As String
>
> entry.Invoke("setPassword", "newpassword")
> entry.CommitChanges()
>
> Response.Write(entry.Password)
>
> Response.Write("successful")
>
> 'Else
> ' Response.Write("your username or password is incorrect")
> 'End If
>
>
>
>
>
> End Sub