0

I'm using this code to filter the groups of my active directory domain:

List<Department> result = new List<Department>();
using (PrincipalContext ctx = getContext())
{
    GroupPrincipal gp = new GroupPrincipal(ctx);
    PrincipalSearcher search = new PrincipalSearcher(gp);
    result = (from g in search.FindAll()
                where !g.DistinguishedName.Contains("CN=Builtin")
                select new Department()
                {
                    name = g.Name,
                    description = g.Description
                }).ToList();
}
return result;

As you can see, I already filter the ones that are included by the system, the builtin ones. But the system has some othes, like the ones created by SQL Server. I need to know if there is a way to show only the ones that were created by the server administrator. Is there a way to do that?

This is my getContext code:

public PrincipalContext getContext()
{
    return new PrincipalContext(ContextType.Domain, WebConfigurationManager.AppSettings["SERVER"].ToString(), WebConfigurationManager.AppSettings["DOMAIN"].ToString() + @"\" + WebConfigurationManager.AppSettings["USER"].ToString(), WebConfigurationManager.AppSettings["PASSWORD"].ToString());
}

And the values on the server are these:

<add key="SERVER" value="192.168.1.2"/>
<add key="DOMAIN" value="intra"/>
<add key="USER" value="xxxxx"/>
<add key="PASSWORD" value="xxxxxxx"/>
Salomon Zhang
  • 1,553
  • 3
  • 23
  • 41
DanielD
  • 47
  • 1
  • 8

1 Answers1

0

The groups that SQL Server creates are local groups on your machine only - they aren't in Active Directory. You'll need to search your local store for those. Open up Local Users & Groups to see those objects.

Cam Bruce
  • 5,632
  • 19
  • 34