allyc has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I am trying to retrieve a users full name as stored on their NT domain user account.

I have managed to retrieve the comments on a users account using the Win32::NetAdmin module. This seems to be able to retrieve any detail about User Accounts accept the name using the UserGetAttributes function.

Any one managed to achieve this in the past??? Am I just missing something with the documentation?

Thanks,

Alistair

Replies are listed 'Best First'.
Re: Getting a Users Name from a Domain
by The Mad Hatter (Priest) on Apr 24, 2003 at 22:11 UTC
    See Win32:Getting the Full Name from User Manager.

    Update Win32API::Net can be used as well:

    use Win32API::Net; my %info = (); my $server = "wonderland"; my $username = "The Mad Hatter"; UserGetInfo($server, $username, 10, \%info); print "$username is $info{fullName} \n";
    That code is untested (no access to a Windows machine), but it should work after you correctly set $server and $username. ;-) See the POD for Win32API::Net for more information about what other user info you can obtain.

    Update 2 Looks like I forgot about the domain part. I'm not sure that first link will help any.

Re: Getting a Users Name from a Domain
by AcidHawk (Vicar) on Apr 25, 2003 at 05:23 UTC

    Have you tried Win32:AdminMisc

    #! /usr/bin/perl use strict; use warnings; use Win32::AdminMisc; my (@users, @groups); print "List of USERS\n"; Win32::AdminMisc::GetUsers("","",\@users); foreach my $usr(@users) { print "$usr\n"; }

    I have tested on a local server, but I know you can add the PDC name and get the info from there.

    -----
    Of all the things I've lost in my life, its my mind I miss the most.
Re: Getting a Users Name from a Domain
by allyc (Scribe) on Apr 24, 2003 at 22:39 UTC
    Thanks for that quick response.

    I have just tried the Win32API::Net method and that seems to work ok on my local machine. I will try on the domain tomorrow. I am guessing that I will have to work out the Primary Domain Controllers Name before I can use the UserGetInfo function though.

    I think that Win32:NetAdmin's GetDomainController will help there.

    I will let you know how I get on!

    Again many thanks.

    Alistair