Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Active Directory search

Status
Not open for further replies.

vvlad

Programmer
May 27, 2002
151
DE
Hi,

I am doing an Active Directory search with Perl. It works OK, except that I can not retrieve the groups which names contain a white space.

Any ideas on how to correctly build the filter?

Thanks,

vlad
 
You should have no problem accessing OU named with space in between. Same goes for CN. You must have missed out something.

Post your codes like Paul said.
 

Here it is, nothing special in it:

Code:
use Net::LDAP;
$ldap = Net::LDAP->new('server_name:port_no') or die "$@";

# works only with authentication
$rc = $ldap->bind('domain\user', password => 'pwd');
die $rc->error if $rc->code;

my $base = "ou=Organizations,ou=Groups,dc=my_region,dc=my_company,dc=com";
my $scope = "subtree";

$groups = "myGroups";

my $filter = "(cn=$groups)";
	
$mesg = $ldap->search(
	base => $base,
	scope => $scope,
	filter => $filter
	);

$mesg->code && die $mesg->error;
$i = 0;

foreach $entry ($mesg->all_entries)
{
	@uid = $entry->get('cn');
	print $uid[0] . "\n";
}

$ldap->unbind;

If $groups contains a space, nothing is found, otherwise works OK.

vlad
 
have you tried encoding spaces?
"My Groups"--> "My%20Groups"?
--Paul

cigless ...
 

Yes I did, but it didn't work.

vlad
 
Sorry guys, I was using an old directory schema, it actually works without problems.

vlad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top