vendredi 4 avril 2014

how can I list all the printers in Active Directory using *principal (c#)


Vote count:

0




I need a list with all the printers in AD, I can list users, groups and pc's but I don't know how to do it with printers. Is it possible to achieve it without using DirectorySearcher.


I used this code to list my users, groups, and pc's. Can I use something similar to list printers.



try {
domain = new PrincipalContext(ContextType.Domain, @"mydomain", @"user", @"pass");

}//try
catch (Exception ex) {
return false;
}//catch
PrincipalSearcher searcher = new PrincipalSearcher();
UserPrincipal finduser = new UserPrincipal(domain);
searcher.QueryFilter = finduser;
PrincipalSearchResult<Principal> Users = searcher.FindAll();
Response.Write("USUARIOS</br>");
foreach (var usr in Users)
{
Response.Write(usr.DisplayName+" ");


}//foreach


asked 25 secs ago






Aucun commentaire:

Enregistrer un commentaire