print "Direct Reports: $adsuser->{directReports}\n";

s/b

foreach $rpt (@{$adsuser->{directReports}}) {
  print "direct report = " . $rpt . "\n";
} 

HTH

Steven
________________________________

        From: [email protected]
[mailto:[email protected]] On Behalf Of
A F
        Sent: Saturday, November 13, 2010 2:20 AM
        To: James Alarie
        Cc: [email protected]
        Subject: Re: Perl and Net::LDAP
        
        
        I am having issue on printing "Direct Reports" of a manager. It
is printing           Direct Reports: ARRAY(0x19a4ad4)
        How can I print the values instead of the array reference?
         
        use Win32::OLE;
        my $userid = &Win32::LoginName;
        my $sysinfo = Win32::OLE->new('ADSystemInfo') || die ("Can't get
sysinfo: " .Win32::OLE->LastError()."\n");
        my $userDN;
        if ( $ARGV[0] )
         {
           ($first,$last) = split (/\./,$ARGV[0]);
           $userDN = "cn=$last\\,
$first,cn=users,DC=internal,DC=compaq,DC=com";
         }
        else
         {
           $userDN=$sysinfo->{UserName};
         }
        my $adsuser = Win32::OLE->GetObject("LDAP://$userDN") || die
("Can't find user: ".Win32::OLE->LastError()."\n");
        print "CN: $adsuser->{cn}\n";
        print "Email address: $adsuser->{EmailAddress}\n";
        print "Username: $adsuser->{Samaccountname}\n";
        print "Manager: $adsuser->{Manager}\n";
        print "Direct Reports: $adsuser->{directReports}\n";
        
        ------------------------------------------------------------
        Also when using Net:LDAP,
        This code only print only one single "Direct Reports"'s name .
Any idea why?
         
        use Net::LDAP;
          
        $ldap = Net::LDAP->new( 'server.company.com:389' ) or die "$@";
        $mesg = $ldap->bind;
        $user = &Win32::LoginName;
        $user = $ARGV[0];
        $mesg = $ldap->search( #
                                base =>
"CN=Users,DC=internal,DC=compaq,DC=com",
                                 filter => "(&(samAccountname=$user) )"
        );
        

        $mesg->code && die $mesg->error;
        my($entry);
        @all = $mesg->entries;
        foreach $ent (@all)
        {
          foreach $att (sort $ent->attributes )
           {
             if ( $att =~ m!\bmail\b! )
              {
                 print "$att -----" . $ent->get_value($att) . "---\n";;
              }
              if ( $att =~ m!manager! )
              {
                 print "$att ----- " . $ent->get_value($att) . "---\n";;
              }
              if ( $att =~ m!directReports! )
              {
                 print "$att ----- " . $ent->get_value($att) . "---\n";;
              }
                    
            }
        }
        
        ________________________________

        From: James Alarie <[email protected]>
        To: A F <[email protected]>
        Sent: Fri, October 22, 2010 12:50:31 PM
        Subject: Re: Perl and Net::LDAP
        
        
        I don't remember having any sample code to offer anyone, so I
tried a Google search to see what I might have had.  I found multiple
sites where I asked for help, but no sample code.

        
        

        The only reponses that I found that were of help to me mentioned
that I had to be running as the System Administrator.  I do remember
that doing that fixed my problem.

        
        

        I'm now retired and no longer have access to my work machine.
The only files I have on my home computer are very early test files with
minor sections of code as I was testing pieces.  I don't expect them to
be of any use, and they may contain something considered PRIVATE to my
previous employer.

        
        

        Sorry.  I wish I could help, but it's been seven years, and I
don't remember much about that project.  Most of my work since then has
been HTML, XHTML, JavaScript, and CSS, plus a small amount of VBScript.

        
        


        --- On Fri, 10/22/10, A F <[email protected]> wrote:
        


                From: A F <[email protected]>
                Subject: Re: Perl and Net::LDAP
                To: "James Alarie" <[email protected]>
                Date: Friday, October 22, 2010, 12:44 PM
                
                
                Thank you very much.
                I was googling for perl and Active directory and your
post came up from a forum and from there I went to your web site.
                

                ________________________________

                From: James Alarie <[email protected]>
                To: [email protected]
                Sent: Fri, October 22, 2010 8:40:06 AM
                Subject: Re: Perl and Net::LDAP
                
                
                I haven't worked with LDAP in over six years; I'll have
to go looking for whatever I might have saved on that.  Just curious:
where did you get my address with reference to this stuff?

                
                


                --- On Fri, 10/22/10 3:11 AM, [email protected] wrote:
                

                
                

                 Hi James,
                
                Can you send me your sample code to create, modify users
in Active Drectory?
                I am having difficulties creating account.
                
                Thanks
                Alain
                        



        

_______________________________________________
Perl-Win32-Admin mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to