Hi Justin,

On Wed, Jan 6, 2016 at 1:28 PM, Justin Alcorn <jbalc...@gmail.com> wrote:

> Your issue is that your perl logic has only one loop, over the first
> group. You need to search and then start processing the groups with
> pop_entry.
>

thanks for the tip!

I have this now which seems to work properly:

my @members;
my $samaccount;
$mesg = $ldapprod->search(
    base   => $prod_base,
    filter => "(objectclass=group)",
    scope  => 'sub',
    attrs  => [
        ( $index > 0 ) ? "member;range=$index-*" : 'member',
'samaccountname',
    ]
);
if ( $mesg->code == LDAP_SUCCESS ) {

    #my $entry = $mesg->entry(0);
    while ( my $entry = $mesg->pop_entry() ) {
        my $attr;

        # large group
        if ( ($attr) = grep( /^member;range=/, $entry->attributes ) ) {
            push( @members, $entry->get_value($attr) );
            $samaccount = $entry->get_value('samaccountname');

            if ( $attr =~ /^member;range=\d+-(.*)$/ ) {
                $index = $1;
                $index++ if ( $index ne '*' );
            }
        }

        # small group
        else {
            @members    = $entry->get_value('member');
            $samaccount = $entry->get_value('samaccountname');
        }
        print "Group: $samaccount\n";
        for (@members) {
            print "$_\n";
        }
        print "=" x 72 . "\n";
    }

}

Thanks again, i have to look into the paging limits as well, as you
mentioned. Small steps.

-- 
regards,
natxo

Reply via email to