Thank you very much Jeremy. 
If I can get a copy of your automated AD account creation, that will be great.
I am having 2 problems with mine
We are still on Exchange 2003, so even I was able to automatically create user 
account in AD, I am having hard time creation mailbox.
Also I will be curious to know how you did the web based since I've tried that 
but failed because I couldn't get the service account with domain admins rights 
to work correctly on the web.

Thanks you so much
Alain




________________________________
From: Jeremy Fluhmann <[email protected]>
To: A F <[email protected]>
Cc: James Alarie <[email protected]>; [email protected]
Sent: Sat, November 13, 2010 11:46:48 AM
Subject: Re: Perl and Net::LDAP

I haven't done much with Win32 and Active Directory stuff in a while, but aside 
from that, you might use something similar to the following to print out the 
array:

......
print "Username: $adsuser->{Samaccountname}\n";
print "Manager: $adsuser->{Manager}\n";
print "Direct Reports: ";
foreach my $report ( @{$adsuser->{directReports}} ) {
    print $report,"\n";
}

In a former job, I created an automated AD account creation program.  It was 
web-based and used Catalyst, but if you still need help with your program, I'd 
be happy to dig up my code and share with you.

Hope that helps,
Jeremy
-- 
Jeremy Fluhmann
http://twitter.com/jfluhmann
http://identi.ca/jfluhmann
Open Source Symposium - http://texasoss.org/
Texas Linux Fest - http://www.texaslinuxfest.org/
TCEA Strategic Open Source SIG - http://sos.tcea.org/



On Sat, Nov 13, 2010 at 3:19 AM, A F <[email protected]> wrote:

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
>>Alai  


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

Reply via email to