Skip to content

Instantly share code, notes, and snippets.

@VTacius
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VTacius/ab9bce4c79987582ea42 to your computer and use it in GitHub Desktop.
Save VTacius/ab9bce4c79987582ea42 to your computer and use it in GitHub Desktop.

Dicho rápido y fácil, esto equivale a ejecutar con ldapsearch desde consola

$ ldapsearch -Y EXTERNAL -H ldapi:///

Será necesarios que las ACL permiten al usuario root para que tenga permisos de lectura donde el administrador tiene permisos de escritura:

olcAccess: {0}to attrs=userPassword,shadowLastChange,sambaLMPassword,sambaNTPassword
  by self write
  by anonymous auth
  by dn="cn=admin,dc=sv" write
  by dn="cn=admin,dc=hacienda,dc=gob,dc=sv" write
  by dn.regex="^cn=admin,(dc=\w+(,)?){1,3}$" read
  by dn="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read
...

Y claro, no debe tener límites alguno en el uso de recursos:

olcLimits: {1}dn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" time.soft=unlimited time.hard=unlimited size.soft=unlimited size.hard=unlimited

Con Servidor Samba con LDAP NSS – PAM en Debian Wheezy no debería preocuparse por estos detalles

En la mayoría de casos, sería necesario instalar Authen::SASL. En Debian:

$ aptitude install libauthen-sasl-perl

Y por fin, el tan ansiado código se reduce a esto:

my $ldap = Net::LDAP->new("ldapi://%2fvar%2frun%2fslapd%2fldapi") or die "$@";
    my $sasl = Authen::SASL->new(mechanism => 'EXTERNAL');
    my $sasl_client = $sasl->client_new('ldap', 'localhost');
    $ldap->bind(undef, sasl => $sasl_client);
    my $msg = $ldap->search(
    ...

Basado en la información tomado de acá, acá y acá

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment