Posts

Showing posts from December, 2011

Active Directory - Change Password

Imports System.DirectoryServices Partial Class _Default     Inherits System.Web.UI.Page     Private Sub ChangeUserADPassword(ByVal Username As String, ByVal Password As String, ByVal newPwd As String)         Dim dcDNS As String = "rockworth.local"         Dim rootDN As String         Dim rootDSE As DirectoryEntry         Dim searchRoot As DirectoryEntry         Dim userEntry As DirectoryEntry         Dim searcher As DirectorySearcher         Dim results As SearchResultCollection         Dim result As SearchResult         Dim oldPassword As String = Password         Dim newPassword As String = newPwd         Try             result = Nothing             rootDSE = New DirectoryEntry(String.Format("LDAP://{0}/rootDSE",dcDNS), Username, oldPassword, AuthenticationTypes.Secure Or AuthenticationTypes.Sealing Or AuthenticationTypes.ServerBind)             rootDN = DirectCast(rootDSE.Properties("defaultNamingContext").Value, String)