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
Christrian BP
  • 67
  • 1
  • 9
  • Hello Christian, this post is quiet old but is there any chance you could share the code to list all the printers on AD using a filter say "location" – Clint May 25 '18 at 04:59
  • you could do something like this [link](https://stackoverflow.com/a/13013562/3499864) – Christrian BP May 30 '18 at 18:34

1 Answers1

0

Found the answer

DirectorySearcher works well just be sure to write the correct domain, user, password and use the right filter.

Christrian BP
  • 67
  • 1
  • 9