Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate user using DirectoryService
    text
    copied!<p>So I managed to get some code rolling for updating the AD from an external sourced. However, I'm a bit confused about how it works. I have a person with sAMAccount xxxx existing in different OUs. Now, I only want to update the info in a specific OU, so I put that in my LDAP path. Still, it seem that the info has been updated in different OU's as well?</p> <p>Could that be possible? Is it because there's only one "Person" object, or do the "GetDirectoryEntry()" not put me where I thought in the tree? Or.. am I only imagine and the weird things I see is becausde of something else. </p> <p>Some code</p> <pre><code> DirectoryEntry entry = new DirectoryEntry(LDAP://my.path/ou=myou, dc=my, dc=path); entry.Username = myUser entry.Password = myPass DirectorySearcher searcher = new DirectorySearcher(entry); searcher.Filter = @"(&amp;(objectClass=Person)(SamAccountname=" + person.id + "))"; SearchResult result = searcher.FindOne(); try { DirectoryEntry user = result.GetDirectoryEntry(); user.Properties["displayName"].Value = person.DisplayName; user.Properties["givenName"].Value = person.Firstname; user.CommitChanges(); user.Close(); } catch (DirectoryServicesCOMException ex) </code></pre> <p>EDIT: It did update the Person object in all the OU's. So either the Person object is one and the same in the whole AD, whick makes my attempt to update them in only the specific OU pointless, or does the "result.GetDirectoryEntry" ignore the fact that I thought I was working only in my specific OU declared in my LDAP path.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload