Subject: | Possible bug or just user error with contacts in groups |
Hi,
I don't know if this is user error on my part due to not understanding
enough about AD or your classes, a bug/foible due to the potentially
odd way we use AD or something else.
Anyway I'm trying to recursively find all users in a group and any of
its subgroups and I hit a few issues with it failing when calling
fetch_secondary_users with a "can't find user" message, after a bit of
checking of AD, this always seems to occur when there is a contact, as
opposed to a proper user in the group, and its always the contact
referred to in the error message.
Changing line 141 in Net/LDAP/Class/Group/AD.pm from
if ($user) {
to
if (defined($user)) {
Has cured my issue, although doing a straight print of the $user or
$user->sAMAccountName throws an error about it being undefined, which
makes sense I think, they won't have an account name if they are only a
contact rather than a full user.
If this is in fact operating as expected, can you suggest a way for me
to list all secondary users and just catch these croaks and carry on.
On a related note, and this one is undoubtedly more due to me abusing
your class and not knowing an easy way to distinguish a user from a
group, but if I try and do a fetch_primary_users or (by inclusion) a
users on a user instead of a group, it throws an error about "Use of
uninitialized value in concatenation (.) or string at
Net/LDAP/Class/Group/AD.pm line 105, <DATA> line 408.". I was able to
fix that by changing line 105-110 in Net/LDAP/Class/Group/AD.pm from
my @users = $user_class->find(
scope => 'sub',
filter => "(primaryGroupID=$pgt)",
ldap => $self->ldap,
base_dn => $self->base_dn,
);
to the rather hacky
my @users = undef;
if (defined($pgt)) {
my @users = $user_class->find(
scope => 'sub',
filter
=> "(primaryGroupID=$pgt)",
ldap => $self->ldap,
base_dn => $self->base_dn,
);
}
Although its just occurred to me that some testing of the existence of
sAMAccountName or similar may help to differentiate users from groups
and contacts.
Thanks,
PN