active directory - C# DirectorySearcher obtain users by manager logon id -


i have 2 issues.

  1. obtain user based on logon name. in image aduser1, can see logon name 'aduser1' not able obtain users though can obtain using first name, sn , on.

    using (directorysearcher searcher = new directorysearcher(domain)) {     searcher.filter = "(&(objectcategory=person)(objectclass=user)(samaccountname=aduser1))";      //searcher.propertiestoload.addrange(new string[] { "givenname", "sn", "samaccountname" });      foreach (searchresult user in searcher.findall())     {         console.writeline(string.format("user {0} {1} ({2}) works john doe", user.properties["givenname"][0].tostring(), user.properties["sn"][0].tostring(), user.properties["samaccountname"][0].tostring()));                             } } 
  2. i want obtain list of users particular manager logon cannot seem format query correctly. example, if want obtain users manager 'aduser1'?

    searcher.filter = "(&(objectcategory=person)(objectclass=user)(manager=aduser1))"; 


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -