CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Win32 Programming Help:
Finding the Group Membership of a User

 



steggles
New User

Jan 30, 2008, 4:18 PM

Post #1 of 6 (5574 views)
Finding the Group Membership of a User Can't Post

Hi (i'm new here),

I did alot of perl programming in university, and I have fond memories of it.

I am currently writing a perl script to create personal settings for users that use manditory profiles. As in, when they log on all open office settings / firefox settings and other application settings are set on the fly using perl.

But in order to correctly setup the profile I need to know the groups a user is in. I havent come across any code that does this, is it possible in perl?


KevinR
Veteran


Jan 30, 2008, 5:13 PM

Post #2 of 6 (5573 views)
Re: [steggles] Finding the Group Membership of a User [In reply to] Can't Post

I recommend you search CPAN for the Win32 modules and search through them and see if there is one that provides this function. I don't know off the top of me head if there is one or not.
-------------------------------------------------


steggles
New User

Jan 30, 2008, 6:04 PM

Post #3 of 6 (5571 views)
Re: [KevinR] Finding the Group Membership of a User [In reply to] Can't Post

Thanks very much kevin for the prompt reply!

I found this beauty!
Win32::AD::User
http://search.cpan.org/~prefect/Win32-AD-User-0.04/User.pm

But I am having 2 issues:

1) If i do the AdUser->new as specified, i get:
Can't locate object method "new" via package "AdUser" (perhaps you forgot to load "AdUser"?)
when I try to run the script
and
2) When I go Win32::AD::User::new (instead of AdUser->new) i get this error:
Win32::AD::User -- Warning USER_REFERENCE_STRING not defined.

Although Im not sure whether what I have written in the USER_REFERENCE_STRING is correct, it is most definately defined.

If this all proves too much effort i'll probably just write my own routines to do what I want, but I would much prefer it if i did not have to do that.


KevinR
Veteran


Jan 30, 2008, 8:06 PM

Post #4 of 6 (5564 views)
Re: [steggles] Finding the Group Membership of a User [In reply to] Can't Post

I assume you successfully installed the module. Post your code. I have never used the module but maybe there is something I can spot in your code.
-------------------------------------------------


steggles
New User

Jan 30, 2008, 8:49 PM

Post #5 of 6 (5561 views)
Re: [KevinR] Finding the Group Membership of a User [In reply to] Can't Post

This is basically what i want to achieve. I hope I am not too clueless.

use strict;
use warnings;

use Win32::AD::User;
use Win32::OLE;

my $user = Win32::AD::User::new("LDAP://cn=username,ou=Computer Department,ou=Administration,ou=Company,ou=Corporate,dc=domain,dc=com", "username") or die "error $!";

@groups = $user->get_groups();
foreach (@groups) {
print ("Group: $_ \n");
}

Although I would read into an array and then do things to the profile per group membership, but printing out the group membership i good enough for testing.


KevinR
Veteran


Jan 30, 2008, 9:58 PM

Post #6 of 6 (5559 views)
Re: [steggles] Finding the Group Membership of a User [In reply to] Can't Post

The code you posted should not even complie since @groups has not been declared with "my". But I will assume your script does include that. The code you posted looks OK to me from what I can tell by looking at the modules documentation. I don't know what an LDAP connection string looks like so I assume what you posted is correct and that "username" is the name of a real user.
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives