Update a user's data in the AD

badblueboy

Member
Joined
Mar 12, 2007
Messages
7
Programming Experience
Beginner
hi @ll,

in my application exists a function where I give a user's properties to a form. There I can edit the user and "save" it. I searched now for a while in google for an example of an update-function for the AD in VB.Net but I havn't found anything :-S

I know that something like this exists, but I just can't find any examples :-(

Does anybody know a site with such an, pretty easy hopefully, example? Or does anybody has one?

I would really appreciate that..it's pretty urgent, because I have to be done with the whole application in wednesday...


greets BBB
 
because that's all (at least the first few hits) about CONNECTING TO THE ACTIVE DIRECTORY, but that ain't my problem. I CAN connect to the AD and read data from it, but I don't know how to save changes in a users properties..

greets
 
I did it!

Private Sub UpdateADPersonData_Do()

' Aktion(en) durchführen : User zu updaten lesen
Dim dirSearcher As New DirectorySearcher
Dim dirResult As SearchResult
Dim dirEntry As DirectoryEntry

dirSearcher = New DirectorySearcher(New DirectoryEntry(mstrLoginADSConnectionString, mstrLoginUserID, mstrLoginKennwort))

dirSearcher.Filter = "(objectClass=user)"
dirSearcher.Filter = "(&" & dirSearcher.Filter & "(samaccountname=" & mstrUserID & "))"

mdirSearchResultat = dirSearcher.FindAll()
If mdirSearchResultat.Count = 1 Then
dirEntry = mdirSearchResultat(0).GetDirectoryEntry
If Len(strsamaccountname) > 0 Then dirEntry.Properties("sAMAccountname").Value = strsamaccountname
If Len(strsn) > 0 Then dirEntry.Properties("sn").Value = strsn
If Len(strgivenname) > 0 Then dirEntry.Properties("givenName").Value = strgivenname
If Len(strc) > 0 Then dirEntry.Properties("c").Value = strc
If Len(strstreetAddress) > 0 Then dirEntry.Properties("streetAddress").Value = strstreetAddress
If Len(strl) > 0 Then dirEntry.Properties("l").Value = strl
If Len(strmobile) > 0 Then dirEntry.Properties("mobile").Value = strmobile
If Len(strtelephonenumber) > 0 Then dirEntry.Properties("telephonenumber").Value = strtelephonenumber

dirEntry.CommitChanges()
End If

dirSearcher = Nothing

End Sub

That's the function that saves changes in the AD - dirEntry.CommitChanges().

But I got another question - how can I set a PASSWORD for a user? I read something about the property "Password()" but I ain't sure if this is it...


greets
 
Back
Top