Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

.net directorysearcher get manager accountname

if (userAccount.Properties["manager"].Value != null)
{
  DirectorySearcher search2 = new DirectorySearcher(domain.GetDirectoryEntry())
  {
    Filter = string.Format("(distinguishedName={0})", userAccount.Properties["manager"].Value)
  };
  search2.PropertiesToLoad.Add("displayName");
  search2.PropertiesToLoad.Add("mail");
  search2.PropertiesToLoad.Add("manager");
  DirectoryEntry mgrAcc = search2.FindOne()?.GetDirectoryEntry();
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #directorysearcher #manager #accountname
ADD COMMENT
Topic
Name
4+7 =