active directory - C# DirectorySearcher obtain users by manager logon id -
i have 2 issues.
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())); } }
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
Post a Comment