Click here to Skip to main content
15,921,062 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Hello!

I am trying to update the logged on user's AD properties, but for some reason it is not updating. below is the Button sub routine. Any ideas would be great!! I am not getting any errors when I run it local, but nothing happens, no update.


Protected Sub update_user_information(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim sPath As String = "LDAP://"
Dim dirEntry As New DirectoryEntry(sPath, "Admin", "Password")
Dim dirSearcher As DirectorySearcher = New DirectorySearcher(dirEntry)

dirSearcher.Filter = [String].Format("(SAMAccountName={0})", System.Environment.UserName)
dirSearcher.SearchScope = SearchScope.Subtree
dirSearcher.PropertiesToLoad.Add("cn")
dirSearcher.PropertiesToLoad.Add("company")
dirSearcher.PropertiesToLoad.Add("description")
dirSearcher.PropertiesToLoad.Add("homePhone")
dirSearcher.PropertiesToLoad.Add("department")
dirSearcher.PropertiesToLoad.Add("mail")
dirSearcher.PropertiesToLoad.Add("telephoneNumber")
Dim searchResults As SearchResult = dirSearcher.FindOne()
Dim dirEntryResults As New DirectoryEntry(searchResults.Path)

If dep.Text <> "---" Then
dirEntryResults.Properties("department").Add(dep.Text)
End If

'If textbox_Office_Phone.Text <> "---" Then
'dirEntryResults.Properties("telephoneNumber").Add(textbox_Office_Phone.Text)
'End If

dirEntryResults.CommitChanges()

dirEntryResults.Close()
End Sub

Posted

1 solution

wrote:
If dep.Text <> "---" Then


Are you sure that this is ever evaluating to true?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900