Question Get Active Directory Users in a Container with a filter

sharpharp

New member
Joined
Dec 10, 2020
Messages
1
Programming Experience
Beginner
Hi,

New to C#, using it with a SSIS package to get a list of users from an OU and child containers beginning with Z1

C#:
              GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx, IdentityType.Name, "My AD Group"); // i just tried this with AD Group to start with and this works
            //The group was found, loop through each of the group's members
            foreach (UserPrincipal p in grp.GetMembers(true))
            {
                //Get the user details
                UserPrincipal user = UserPrincipal.FindByIdentity(ctx, p.SamAccountName);
                UserPrincipalEx userEx = UserPrincipalEx.FindByIdentity(ctx, p.SamAccountName);

But i'd like to have an OU instead of an AD Group and then also only include Accounts beginning with Z1

Any help appreciated as i aint got a clue

Thanks
 
Last edited by a moderator:
Time to read up on LDAP queries... Anyway, this should give you a major boost forward if you don't want to bother learning about LDAP:
 
Back
Top Bottom