CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2010

    Reseting a users password via Active Directory using Visual Basic 2010..

    Hi Guys im writing a little app to enable authorised staff to reset student passwords but having a few issues. . I am no expert and am now stuck!

    The following code does not seem to error but also does not reset the password!


    Private Sub bt_pwd_reset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_pwd_reset.Click

    tb_newpwd1.Text = GenPassword.ToString


    Dim username As String = TUserName.Text
    Dim de As DirectoryEntry = New DirectoryEntry()
    de.Path = "LDAP://;dc=domain,dc=domain,dc=internal"

    de.Username = "DOMAIN\username-admin"
    de.Password = "domainpassword"

    de.AuthenticationType = AuthenticationTypes.Secure

    Dim deSearch As DirectorySearcher = New DirectorySearcher(de)
    deSearch.SearchRoot = de
    deSearch.Filter = ("(sAMAccountName=" & username & ")")
    Dim results As SearchResultCollection = deSearch.FindAll()
    If results.Count = 0 Then
    message.Text = "Can not locate user name: " & username
    message.Visible = True
    Exit Sub
    End If

    With de
    .InvokeSet("serPassword", "Password123")
    ' .Invoke("SetPassword", Password123)
    End With


    Catch ex As Exception
    message.Text = ex.ToString
    End Try
    lb_bigpwd.Text = tb_newpwd1.Text
    End Sub


    Any help on this would be great!!

    Thanks in advance

  2. #2
    Join Date
    Jan 2006
    Fox Lake, IL

    Re: Reseting a users password via Active Directory using Visual Basic 2010..


    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.