Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

394
Views
Obtenga el recuento de resultados = 0 cuando consulte el correo electrónico de un usuario por ldap_search

Necesito escribir un script para obtener información de usuario en un servidor LDAP. Esto funciona bien si no filtro nada, pero si configuro el filtro para un usuario específico, el resultado siempre es 0. Sospecho de la cadena de filtro, pero no estoy seguro de eso.

Aquí está el código:

 <?php // using ldap bind $ldaprdn = 'uid=riemann,dc=example,dc=com'; // ldap rdn or dn $ldappass = 'password'; // associated password // connect to ldap server $ldapconn = ldap_connect("ldap.forumsys.com") or die("Could not connect to LDAP server."); ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0); if ($ldapconn) { // binding to ldap server $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass); // verify binding if ($ldapbind) { echo "LDAP bind successful..."; } else { echo "LDAP bind failed..."; } } $attributes = array('mail'); $accountname = "*"; //fine if =*, 0 if set it = riemann $filter_person = "(&(sAMAccountName={$accountname}))"; echo $filter_person; $search = ldap_search($ldapconn,"DC=example,DC=com", $filter_person, $attributes); $data = ldap_get_entries($ldapconn, $search); print_r($data); ?>
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Me lo imaginé. Es mi culpa que configuré mal $filter_person .

Debería ser:

 $filter_person = "uid={$accountname}";
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!