DN	Distinguished Name         e.g.   cn=george+sn=george,ou=Admins,dc=ec2-54-93-95-144.eu-central-1.compute.amazonaws,dc=com
DC	domainComponent            e.g.   dc=local,dc=lan          
CN	commonName                 e.g.   cn=Users
OU	organizationalUnitName     e.g.   ou=BackupOperators
O	organizationName 
STREET	streetAddress
L	localityName
ST	stateOrProvinceName
C	countryName
UID	userid


query using curl

	curl -u bourasg@unisystems.gr "ldap://10.24.17.20/CN=Bouras George,OU=Users,OU=ISO27001,DC=unisystems,DC=gr?sAMAccountName,memberOf"
	
	


How to search
-------------

base      : what to search                           e.g. 'CN=Users,DC=local,DC=lan'
callback  : Run this code for every record           e.g   \&Somesubroutine
attrs	  : Bring only these fields of every record  e.g.  ['name' , 'memberOf'];
typesonly : 0 return values , 1 only the field names
scope     : how deep to search

      base	Search only the base object.
      one	Search the entries immediately below the base object.
      subtree 	The default. Search the whole tree below (and including) the base object. This is the default.
      children	Search the whole subtree below the base object, excluding the base object itself.

filter   : match filter

         filter       = "(" filtercomp ")"
         filtercomp   = and / or / not / item
         and          = "&" filterlist
         or           = "|" filterlist
         not          = "!" filter
         filterlist   = 1*filter
         item         = simple / present / substring / extensible
         simple       = attr filtertype value
         filtertype   = equal / approx / greater / less
         equal        = "="
         approx       = "~="
         greater      = ">="
         less         = "<="
         extensible   = attr [":dn"] [":" matchingrule] ":=" value   [":dn"] ":" matchingrule ":=" value
         present      = attr "=*"
         substring    = attr "=" [initial] any [final]
         initial      = value
         any          = "*" *(value "*")
         final        = value
         attr         = AttributeDescription from Section 4.1.4 of RFC 4511
         matchingrule = MatchingRuleId from Section 4.1.8 of RFC 4511
         value        = AttributeValue from Section 4.1.5 of RFC 4511
e.g.
    '(CN=Admin*)'
    "&(sAMAccountName=user1)(sAMAccountType=805306368)"    username   user1 KAI  sAMAccountType   805306368    
    "&(sAMAccountName=user1)(sAMAccountName=user9)"        username   user1    user9
    "(|(physicalDeliveryOfficeName=100)(physicalDeliveryOfficeName=274))(&....   )";

full example

	my $mesg =  $ldap->search
		(
		base      => 'OU=Users,OU=ISO27001,DC=unisystems,DC=gr',
		filter    => '(sAMAccountType=805306368)',
		attrs     => ['name' , 'memberOf'],
		scope     => 'one',
		typesonly => 0,
		timelimit => 0,
		sizelimit => 0
		);
	
	$mesg->code && Exit( $mesg->error );
	print $mesg->count; # number of results



	## If there is only one result
	print $mesg->entry->{asn}->{objectName}  if $mesg->count == 1;

	## Results as array	

		foreach my $entry ($mesg->entries)
		{
		print $entry->dump                                      ,"\n";
		print Dumper $entry                                     ,"\n";
		print $entry->{asn}->{objectName}                       ,"\n";
		print $entry->{asn}->{attributes}->[0]->{vals}->[0]     ,"\n";		
		}

 	## Results as hash

 		foreach my $dn ( keys %{ $mesg->as_struct } )
		{
			foreach my $attr ( keys %{ $mesg->as_struct->{$dn} } )
			{
			print Dumper $mesg->as_struct->{$dn}->{$attr};
			}
		}
