Chris wrote: > Have you tried using the net-ldap module? It does this pretty easily. > [EMAIL PROTECTED] wrote: > > Help! I've been banging my head against the wall on this for a while > > now. I'm trying to write a script to search for a specific user acct. > > The only piece of information I will have is logonid/samaccountname. > > > > [...] > > Is there any way to apply some type of filter like > > &(objectCategory=user)(objectClass=user)(samaccountname=bubslg) to this > > query? Or is there a better way to query for an object that matches a > > specific logonid.samaccountname? > > > > Any ideas would be greatly appreciated.
I'm sure you've managed what you wanted from the other excellent suggestions, but this code did the trick for extracting Home Drive and Profile locations: my $ad = Net::LDAP->new( $DomainController, timeout=>5 ) or die 'Could not connect to AD: ' . $!; $ad_msg = $ad->search( base=>'dc=xxxx,dc=xxxx,dc=com', filter=>"(SamAccountName=$username)", sizelimit=>1, timelimit=>10, scope=>'sub', sizelimit=>1, attrs => ['homeDirectory','profilePath'], callback => \&process_ad_entry ); sub process_ad_entry { my ( $ad_msg, $entry) = @_; # Final callback has no entry if ( defined($entry) ) { my %hash = (); $hash{'home'} = $entry->get_value('homeDirectory') || 'Not Available'; $hash{'profile'} = $entry->get_value('profilePath') || 'Not Available'; display_results ( \%hash, 'data_lines' ); } } This site should give you some ideas on sample LDAP queries: http://www.petri.co.il/ldap_search_samples_for_windows_2003_and_exchange.htm Hope this helps James.