Try this. I found this online.. Other scripts from the same source worked for me. Good
luck.
-Henry
# ------ SCRIPT CONFIGURATION ------
my $strUserDN = "<UserDN>"; # e.g. cn=jsmith,cn=Users,dc=rallencorp,dc=com
# ------ END CONFIGURATION ---------
use Win32::OLE 'in';
$Win32::OLE::Warn = 3;
my $objUser = Win32::OLE->GetObject("LDAP://" . $strUserDN);
print "Group membership for ", $objUser->Get("cn"), ":\n";
my $strSpaces = "";
my %dicSeenGroup;
DisplayGroups("LDAP://$strUserDN", $strSpaces, %dicSeenGroup);
sub DisplayGroups {
my ($strObjectADsPath, $strSpaces, %dicSeenGroup) = @_;
my $objObject = Win32::OLE->GetObject($strObjectADsPath);
print $strSpaces, $objObject->Name,"\n";
if ($objObject->Get("memberOf")) {
$colGroups = $objObject->Get("memberOf");
}
foreach my $strGroupDN (in $colGroups) {
if (not $dicSeenGroup{$strGroupDN}) {
$dicSeenGroup{$strGroupDN} = 1;
DisplayGroups("LDAP://" . $strGroupDN, $strSpaces . " ", %dicSeenGroup);
}
}
}
-----Original Message-----
From: [EMAIL PROTECTED] on behalf of Martin Douglas
Sent: Fri 7/9/2004 1:22 PM
To: [EMAIL PROTECTED]
Cc:
Subject: adsi user groups enumeration
All I want to do is print out the groups a user belongs to. I searched
the list for 'group' but came up with nothing.
Here is my code:
#! C:\perl\bin\perl
use strict;
use warnings;
# script modules usage
use Win32::OLE; # base functionality
# attach to user and
my $oUser = Win32::OLE->GetObject("LDAP://cn=username,DC=test,DC=ca");
my (@aGroups, $sGroup);
@aGroups = $oUser->GetEx('memberOf');
foreach $sGroup (@aGroups) {
print "Group is: $sGroup\n";
}
I have also tried:
@aGroups = $oUser->Groups to no avail.
I definitely is friday afternoon here, I can't get anything done. Any help?
martin
--
*****************************************************************
Martin Douglas (martin at you double-you oh dot see eh)
ITS Network Operations
Information Technology Services
Natural Sciences Centre, Room 209
University of Western Ontario
(519) 661-2111 x81187
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs