PasswordChange



Hi,
I am trying to make self-service password change(reset) page. below is my
code to change password:

Caller section

Dim ob As New LdapAuthentication

Try

ob.changeOldPassword(txtUsername.Text, txtOldPassword.Text,
txtNewPassword1.Text) 'path is LDAP://DC=my,DC=local ** I got error here **

End If

Catch ex As Exception

Response.Write(ex.Message)

End Try



Callee section

Public Function changeOldPassword(ByVal username As String, ByVal
oldpassword As String, ByVal newpassword As String) As Boolean

Try

Const ADS_UF_ACCOUNTDISABLE As Integer = &H2

Dim user As New DirectoryEntry()

Dim domain_username = "domain\" & username

Dim entry As DirectoryEntry = New DirectoryEntry(_path, domain_username,
oldpassword)

Dim bindCheck As Object = entry.NativeObject

Dim search As New DirectorySearcher(entry)

search.Filter = "(sAMAccountName=" & username & ")"

user = New DirectoryEntry(search.FindOne.GetDirectoryEntry.Path)

user.AuthenticationType = AuthenticationTypes.Secure Or
AuthenticationTypes.Sealing

'change password

user.Invoke("ChangePassword", New Object() {oldpassword, newpassword})

Dim flags As Integer = user.Properties("userAccountControl").Value

user.Properties("userAccountControl").Value = flags And Not
ADS_UF_ACCOUNTDISABLE

user.CommitChanges()

Catch ex As Exception

Throw New Exception("ERROR::" & ex.InnerException.InnerException.Message)

End Try

End Function



Problem:

Firstly I got "password policy" error but my new password was within the
policy rule, I can also check the validity of users against AD.

Now I am getting error on (as pointed above ** ....**) "Object reference
not set to an instance of an object. "

Is there anything i overlooked or any mistakes? Anyone any suggestion?

Thanks.


.



Relevant Pages

  • help with directoryentry WinNT
    ... In my hunt to change the "User Cannot Change password" attribute in ... active directory so that its unchecked, I read that it is easier to use ... Dim DSESearcher As New DirectorySearcher ... Dim objProperties = objWinNT.Properties ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Change Password command
    ... Dim ws As Workspace ... > not in the admins group, to open the User and Group Accounts dialog ... > can I force the Change Password tab to be selected when the User ...
    (microsoft.public.access.formscoding)
  • Search pattern
    ... Dim strfile As String ... Dim bAddressFound As Boolean ... Dim strCurrentChar As String ...
    (comp.databases.ms-access)
  • Auto Write Name and Merge across
    ... Dim Sheetname01 As String ... Dim WeekName01 As String ...
    (microsoft.public.excel.misc)
  • Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
    ... Friend Versione As String ... Public Sub GetMyConnectionPalmare() ... Dim errorMessages As String ... Private Function GetDS_Desktop(ByVal SQL As String) As DataSet ...
    (microsoft.public.dotnet.framework.compactframework)