Hi Group,
I am trying to change a users password in Active Directory. I am
getting an error that reads:
"Configuration information could not be read from the domain
controller, either because the machine is unavailable, or access has
been denied."
I can see the users properties, including their password, from the
watch window. The call to ChangePassword is failing. The user I am
connecting to AD as has the rights to change their own password.
I am specifying the IP Address of the DC to connect to it as I cannot
see it via DNS name from my laptop. Any sugestions/tips greatly
appreciated. TIA.
This is the code I am using (which I copied from another post):
rootDSE = New DirectoryEntry(String.Format("LDAP://{0}/rootDSE",
dcDNS), username, oldPassword)
'rootDSE = New
DirectoryEntry(String.Format("LDAP://{0}/rootDSE", dcDNS), "admin",
"i82much", AuthenticationTypes.Secure Or AuthenticationTypes.Sealing Or
AuthenticationTypes.ServerBind)
rootDN =
DirectCast(rootDSE.Properties("defaultNamingContex t").Value, String)
searchRoot = New
DirectoryEntry(String.Format("LDAP://{0}/{1}", dcDNS, rootDN),
username, oldPassword)
searcher = New DirectorySearcher(searchRoot)
searcher.Filter = String.Format("sAMAccountName={0}",
username)
searcher.SearchScope = SearchScope.Subtree
searcher.CacheResults = False
results = searcher.FindAll()
For Each result In results
userEntry = result.GetDirectoryEntry()
Exit For
Next
If userEntry Is Nothing Then
Throw New InvalidOperationException("User not found in
this domain.")
End If
'userEntry.Invoke("ChangePassword", New Object()
{newPassword})
userEntry.Invoke("ChangePassword", New Object()
{oldPassword, newPassword})
userEntry.CommitChanges()