1 2 3
ERROR detected: -> LDAP_ENCODING_ERROR C<Net::LDAP> encountered an error while encoding the request packet that would have been sent to the server ERROR - not LDAP_SUCCESS at ./ldap_group.pl line 34, <DATA> line 774.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#!/usr/bin/perl use warnings; use strict; use Net::LDAP; use Net::LDAP::Util qw(ldap_error_text ldap_error_name); # Uses AD Account my $account = 'MYACCOUNT'; my $pwd = 'PASSWORT'; # Bind to LDAP my $ad = Net::LDAP->new("ldap://SERVER.DOMAIN") or die ("Could not connet to LDAP server."); $ad->bind( $account, password => $pwd, version => 3 ); my $base = "DC=DOMAIN"; my $filter = '(&(objectCategory=Group)(objectClass=group))'; my $attrs = "sAMAccountName, cn, displayName, mail, whenCreated, whenChanged, member, distinguishedName"; # Generate the search my $results = $ad->search(base=>$base,filter=>$filter,attrs=>$attrs); # Check if search has errors if ($results->code) { print "ERROR detected: -> ", ldap_error_name($results->code), " ", ldap_error_text($results->code); warn "ERROR - not LDAP_SUCCESS"; } my $count = $results->count; print "DEBUG: ".$count."\n"; $ad->unbind;