DirectoryEntry Set User Login Password 
Author Message
 DirectoryEntry Set User Login Password

I've scoured the net for a VB example that actually works to allow me to set a user password using DirectoryServices.  Nothing works!  Can anyone help?
The C# examples don't work for me.  I've tried over 20 variations.  Help!

Here's some sample code:

    Private Sub PutActiveDirectoryPassword()
        'This subroutine sets the users login password

        'This is coded for a VB Web Form, this is the
        '  Form.aspx.vb file

        Dim ldapUser As DirectoryEntry
        Dim strLdapContainer As String

        strLdapContainer = "LDAP://CN=Username,_
                           OU=OUName,DC=SITE1,_
                           DC=Domain,DC=com"

        ldapUser = New DirectoryEntry_
                  (strLdapContainer ,_
                  "username", "password", _
                  AuthenticationTypes.Secure)

        Try
            ldapUser.Invoke("SetPassword", "password")
                Try
                        ldapUser.CommitChanges()
                Catch
                        Response.Write("Password _
                        COMMIT failed. Error=" + _
                        Err.Description.ToString + ".<br>")
                End Try
        Catch
                Response.Write("Password _
                SET failed. Error=" + _
                Err.Description.ToString + ".<br>")
        End Try

    End Sub

*** Sent via Developersdex http://www.*-*-*.com/ ***
Don't just participate in USENET...get rewarded for it!



Mon, 05 Jan 2004 11:28:57 GMT  
 DirectoryEntry Set User Login Password
Don,

Do we get a clue as to how and where it is failing?

--
Kathleen
(MS-MVP)
Reply in the newsgroup so everyone can benefit
--



Mon, 05 Jan 2004 21:17:50 GMT  
 DirectoryEntry Set User Login Password
Thanks Kathleen.

The error occurs on the Invoke command to set the password.

"Password SET failed. Error=Unknown error (0x80005000)"

FYI - If I pull the commit statement out into a non-embedded Try statement, I don't get an error for that part.

Do you have a code example that performs this using VB.NET?

Thanks again,

Don

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Mon, 05 Jan 2004 21:48:07 GMT  
 DirectoryEntry Set User Login Password
Hi Don,

You may get more information by using an Exception object rather than the
Err object.

eg: replace the Catch blocks you have a t present with something like :

Catch ex As Exception

Console.Write("Password COMMIT(failed.Error = " & ex.ToString & ".<br>")


Quote:
> Thanks Kathleen.

> The error occurs on the Invoke command to set the password.

> "Password SET failed. Error=Unknown error (0x80005000)"

> FYI - If I pull the commit statement out into a non-embedded Try

statement, I don't get an error for that part.
Quote:

> Do you have a code example that performs this using VB.NET?

> Thanks again,

> Don

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Wed, 07 Jan 2004 13:59:23 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Exception setting password with DirectoryEntry

2. Setting User Password & Forcing Password Change

3. SQL Login and Password after setting .SetLoginInfo

4. HELP:LOGIN DIALOG BOX USER/PASSWORD

5. HELP:LOGIN DIALOG BOX USER/PASSWORD

6. Verify the user password after login

7. Login in using user/password

8. Login in using user/password

9. Login in in vb6 app using NT user and password

10. User Login and Password

11. Retrieving the GUID for each users from the DirectoryEntry

12. Add a AD user to local group using directoryentry

 

 
Powered by phpBB® Forum Software