Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP Zugriff auf LDAP

Empfohlene Antworten

Hallo,

ich habe ein Problem beim Zugriff auf einen LDAP Server.

ich möchte mir alle Abteilungen (ou's) ausgeben lassen und darunter jeweils die dazugehörigen Mitarbeiter. Die Ausgabe aller ou's funktioniert soweit, nur bei der 2. Suche (for-Schleife in einer for-Schleife) stürzt mir der Apache ab.

Hier mein Code:

*code*

<?php

$ldaphost= "server";

if(!($ldap = ldap_connect($ldaphost,389))){

die("ldap server cannot be reached");

}

else {

$oudc = "dc=xyz, dc=de";

$dn2 = "ADS";

$password = "ADSReader";

echo "<pConnected and ready to bind...";

if (!($res = @ldap_bind($ldap, $dn2, $password))) {

print(ldap_error($ldap) . "<BR>");

die ("Could not bind the $dn2");

echo "<pCouldn't bind ....";

}

else {

echo "<p>Binded and Ready to search....";

echo "<br>LDAP = $ldap";

echo "<br>oudc = $oudc";

$filter="(&(objectClass=user)(objectCategory=person)(|(sn=sorg)))";

$filter= "ou=NUP_*";

$sr=ldap_search($ldap,$oudc,$filter);

echo "<pnumber of entries found: " . ldap_count_entries($ldap,$sr) . "<p>";

echo "<br>filter = $filter";

echo "<br>sr=$sr";

if (!$sr) {

die("<p>search failed\n");

}

else {

echo "<p> Searched and ready for get entries..... <br>";

$info= ldap_get_entries($ldap, $sr);

echo "Abteilung: <br>";

for ($i=0; $i<$info["count"]; $i++) {

$temp = $info[$i]["ou"][0];

print (" <br>" .$temp);

//echo "<br> $temp";

$oudc = "ou=$temp, dc=xyz, dc=de";

$filterd = "sn=*";

$srd=ldap_search($ldap,$oudc, $filterd);

echo "<p>number of entries gefunden: " . ldap_count_entries ($ldap,$srd) . "<p>";

echo "<br>filter = $filterd";

echo "<br>srd=$srd";

if (!$srd) {

die("<p>search failed\n");

}

else {

echo "<p> Searched and ready for get entries..... <br>";

$infod = ldap_get_entries($ldap, $srd);

for ($j=0; $j<$infod["count"]; $j++) {

print ($infod[$j]["cn"][0] ." ");

//print ($infod[$j]["department"][0] ."<br>");

}

}

}

}

}

ldap_unbind($ldap);

echo "<p>LDAP unbinded....";

}

?>

*/code*

Das Problem liegt irgendwo bei $infod, wenn ich das auskommentiere stürzt der Apache nicht ab.

Kann mir einer helfen?

Danke, Dirk

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Konto

Navigation

Suchen

Suchen

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.