I am currently trying to allow users to update their AD password online. They authenticate against AD, which works fine, but I am hung up on an error.(below) It seems pretty simple, however the new passwords I am supplying/testing with reach all the requirements.
Code:
Dim user As New DirectoryEntry(_path, domainAndUsername, oldPassword, AuthenticationTypes.Secure And AuthenticationTypes.Sealing)
Dim search As New System.DirectoryServices.DirectorySearcher(user)
search.Filter = ("(samAccountName=" & username & ")")
Dim sr As SearchResult = search.FindOne()
If (Not (sr Is Nothing)) Then
user = sr.GetDirectoryEntry()
'Reset Password
user.Invoke("ChangePassword", New Object() {oldPassword, newPassword}) 'fails here
user.CommitChanges()
End If
Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x800708C5): The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements. (Exception from HRESULT: 0x800708C5) --- End of inner exception stack trace --- at System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args)
Also, this is running on an XP Pro box, if that makes a difference. Any ideas?
Thanks,
JC
Code:
Dim user As New DirectoryEntry(_path, domainAndUsername, oldPassword, AuthenticationTypes.Secure And AuthenticationTypes.Sealing)
Dim search As New System.DirectoryServices.DirectorySearcher(user)
search.Filter = ("(samAccountName=" & username & ")")
Dim sr As SearchResult = search.FindOne()
If (Not (sr Is Nothing)) Then
user = sr.GetDirectoryEntry()
'Reset Password
user.Invoke("ChangePassword", New Object() {oldPassword, newPassword}) 'fails here
user.CommitChanges()
End If
Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x800708C5): The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements. (Exception from HRESULT: 0x800708C5) --- End of inner exception stack trace --- at System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args)
Also, this is running on an XP Pro box, if that makes a difference. Any ideas?
Thanks,
JC