How to query for members of an LDAP group using Powershell not in MS Active Directory

13,024

This will show you all the properties there are:

$deObject | Format-List * -force

And this will return you the number of members in a group:

$deObject.member.Count
Share:
13,024
robbie
Author by

robbie

C# .NET Web Service Developer

Updated on June 04, 2022

Comments

  • robbie
    robbie almost 2 years

    All I am trying to accomplish is to return if an LDAP group has any members in it. So, I have a list of groups, and I want to query each one for a list of members to ensure there is at least 1 member in every group.

    I am using powershell and this is NOT Active Directory.

    This is currently what I am trying

    $user = "username"
    $pwd = "password"
    $de = "LDAP://[SERVERNAME]/cn=user,ou=people,o=company"
    $deObject = New-Object -TypeName System.DirectoryServices.DirectoryEntry($de,$user,$pwd,'FastBind')
    

    This returns a DirectoryEntry object (at least as far as I can tell). I can't really see any attributes or anything except for if I do the following:

    $deObject.Name
    

    This returns the cn of "user" and that's it. Any suggestions?

    I've tried:

    $deObject.Properties
    $deObject.Properties['member']
    $deObject.Properties.Values['member']
    

    Thanks in advance!

  • robbie
    robbie over 11 years
    Thank you for this. I am actually able to get the list of members and the full cn using: $deObject.member and $deObject.Name The odd thing though, is that the $deObject | Format-List * -Force throws an "Unknown error (0x8000500c)"