Guten Tag ich bräuchte bitte Hilfe sitze schon seit einigen Stunden an dem Problem und komme nicht weiter.
Fehlermeldung:
An error occurred. Error number 10: Referral
SERVER-1
mein Serverdddddd -> was über ide Eingabe übergeben wird
mein Server -> ist der Oringinaleintrag
Laut Apache2 Log
ldap_modify(): Modify: Referral in /var/www/html/admin/edit.php on line 50, referer: http://10.10.10.102/admin/ldappclabel.php
doch Ich sehe ihn nicht den Fehler.
zum abfragen Benutze ich diesen eintrag und der Funktioniert
Fehlermeldung:
An error occurred. Error number 10: Referral
SERVER-1
mein Serverdddddd -> was über ide Eingabe übergeben wird
mein Server -> ist der Oringinaleintrag
Laut Apache2 Log
ldap_modify(): Modify: Referral in /var/www/html/admin/edit.php on line 50, referer: http://10.10.10.102/admin/ldappclabel.php
doch Ich sehe ihn nicht den Fehler.
PHP-Code:
<html>
<head>
</head>
<body>
<?php
include '../config/db.php';
include '../datamy.php';
$select=("SELECT `id`, `ldap_username`, `ldap_password`, `ldap_connection` FROM `system-ad` WHERE 1 ");
$db_erg = mysqli_query( $db_link, $select );
if ( ! $db_erg )
{
die('Ungültige Abfrage: ' . mysqli_error());
}
while ($row = mysqli_fetch_array( $db_erg, MYSQLI_ASSOC))
{
$ldap_id=($row['id']);
$ldap_username=($row['ldap_username']);
$ldap_password=($row['ldap_password']);
$ldap_connection=($row['ldap_connection']);
}
$ldap_connection1 = ldap_connect("$ldap_connection");
function ldapTimeToUnixTime($ldapTime) {
$secsAfterADEpoch = $ldapTime / 10000000;
$ADToUnixConverter = ((1970 - 1601) * 365 - 3 + round((1970 - 1601) / 4)) * 86400;
return intval($secsAfterADEpoch - $ADToUnixConverter);
}
if (FALSE === $ldap_connection1){
// Uh-oh, something is wrong...
echo 'Unable to connect to the ldap server';
}
// We have to set this option for the version of Active Directory we are using.
ldap_set_option($ldap_connection1, LDAP_OPT_PROTOCOL_VERSION, 3) or die('Unable to set LDAP protocol version');
ldap_set_option($ldap_connection1, LDAP_OPT_REFERRALS, 0); // We need this for doing an LDAP search.
if (TRUE === ldap_bind($ldap_connection1, $ldap_username, $ldap_password))
$Pc= $_POST["rechner"];
$dn = "CN=$Pc,CN=Computer,CN=Configuration,DC=XXX,DC=XXX";
$beschreibung["description"] = $_POST["label"];
// $result = ldap_mod_replace($ldap_connection1, $dn, $newuser);
// modify data in the directory
$result = ldap_modify($ldap_connection1, $dn, $beschreibung);
// if successful, display success message
if ($result) {
echo "Entry with DN " . $dn . " modified in LDAP directory.";
}
// else display error
else {
echo "An error occurred. Error number " . ldap_errno($ldap_connection1) . ": " . ldap_err2str(ldap_errno($ldap_connection1));
}
echo $_POST['rechner'];
echo $_POST['label'];
// all done? clean up
ldap_close($ldap_connection1);
?> </head> </html>
PHP-Code:
$select=("SELECT `id`, `ldap_username`, `ldap_password`, `ldap_connection` FROM `system-ad` WHERE 1 ");
$db_erg = mysqli_query( $db_link, $select );
if ( ! $db_erg )
{
die('Ungültige Abfrage: ' . mysqli_error());
}
while ($row = mysqli_fetch_array( $db_erg, MYSQLI_ASSOC))
{
$ldap_id=($row['id']);
$ldap_username=($row['ldap_username']);
$ldap_password=($row['ldap_password']);
$ldap_connection=($row['ldap_connection']);
}
$domain=$ldap_connection;
$splitted=explode(".",$domain,2);
//print_r($splitted);
$host=$splitted[0];
$domain=$splitted[1];
$ldap_connection1 = ldap_connect("$ldap_connection");
function ldapTimeToUnixTime($ldapTime) {
$secsAfterADEpoch = $ldapTime / 10000000;
$ADToUnixConverter = ((1970 - 1601) * 365 - 3 + round((1970 - 1601) / 4)) * 86400;
return intval($secsAfterADEpoch - $ADToUnixConverter);
}
if (FALSE === $ldap_connection1){
// Uh-oh, something is wrong...
echo 'Unable to connect to the ldap server';
}
// We have to set this option for the version of Active Directory we are using.
ldap_set_option($ldap_connection1, LDAP_OPT_PROTOCOL_VERSION, 3) or die('Unable to set LDAP protocol version');
ldap_set_option($ldap_connection1, LDAP_OPT_REFERRALS, 0); // We need this for doing an LDAP search.
if (TRUE === ldap_bind($ldap_connection1, $ldap_username, $ldap_password)){
//Your domains DN to query
$ldap_base_dn = "DC=$host,DC=$domain";
//Get standard users and contacts
$search_filter = '(|(objectCategory=computer)(objectCategory=schema)(objectsAMAccountName=samaccountname)(objectDescription=description)(objectOperatingSystem=operatingSystem)(objectOperatingSystemVersion=operatingsystemversion)(objectlastLogon=lastlogon)(objectlastLogoff=lastlogoff)(objectmemberOf=memberof)(objectmember=member))';
//Connect to LDAP
$result = ldap_search($ldap_connection1, $ldap_base_dn, $search_filter);
if (FALSE !== $result){
$entries = ldap_get_entries($ldap_connection1, $result);
// Uncomment the below if you want to write all entries to debug somethingthing
//var_dump($entries);
//Create a table to display the output
echo '<br>';
echo '<table width="80%" border = "1"><tr bgcolor="#cccccc"><td>PC Name</td><td>Beschreibung</td><td>Operating System</td><td>Operating System Version</td><td>Letztes Logon</td><td>Letztes Logoff</td><td>Mitglied von</td></tr>';
//For each account returned by the search
for ($x=0; $x<$entries['count']; $x++){
//Windows Usernaame
$LDAP_samaccountname = "";
if (!empty($entries[$x]['samaccountname'][0])) {
$Samaccountname = $entries[$x]['samaccountname'][0];
$LDAP_samaccountname = substr($Samaccountname,0, -1);
if ($LDAP_samaccountname == "NULL"){
$LDAP_samaccountname= "";
}
} else {
//#There is no samaccountname s0 assume this is an AD contact record so generate a unique username
//$LDAP_uSNCreated = $entries[$x]['usncreated'][0];
//$LDAP_samaccountname= "COMPUTER_" . $LDAP_uSNCreated;
}
$Description = "";
if (!empty($entries[$x]['description'][0])) {
$Description = $entries[$x]['description'][0];
if ($Description == "NULL"){
$Description = "";
}
}
$operatingSystem = "";
if (!empty($entries[$x]['operatingsystem'][0])) {
$operatingSystem = $entries[$x]['operatingsystem'][0];
if ($operatingSystem == "NULL"){
$operatingSystem = "";
}
}
$OperatingSystemVersion = "";
if (!empty($entries[$x]['operatingsystemversion'][0])) {
$OperatingSystemVersion = $entries[$x]['operatingsystemversion'][0];
if ($OperatingSystemVersion == "NULL"){
$OperatingSystemVersion = "";
}
}
$lastLogon = "";
if (!empty($entries[$x]['lastlogon'][0])) {
$lastLogon = $entries[$x]['lastlogon'][0];
$unixTimestamp = ldapTimeToUnixTime($lastLogon);
$lastLogon1 = date('d M Y H:i:s ',$unixTimestamp);
if ($lastLogon == "NULL"){
$lastLogon = "";
}
}
$lastLogoff = "";
if (!empty($entries[$x]['lastlogoff'][0])) {
$lastLogoff = $entries[$x]['lastlogoff'][0];
$unixTimestamp = ldapTimeToUnixTime($lastLogoff);
echo date('d M Y H:i:s ',$unixTimestamp);
if ($lastLogoff == "NULL"){
$lastLogoff = "";
}
}
$memberOf = "";
if (!empty($entries[$x]['memberof'][0])) {
$memberOf = $entries[$x]['memberof'][0];
if ($memberOf == "NULL"){
$memberOf = "";
}
}
?>
<tr><form action="edit.php" method="post" target="">
<td><strong><input type="Text" name="rechner" value="<?php echo $LDAP_samaccountname; ?>" size="20"></td>
<td><input type="Text" name="label" value="<?php echo $Description; ?>" size="30" maxlength="30"></td>
<td><input type="Text" name="" value="<?php echo $operatingSystem; ?>" size="30" maxlength=60"></td>
<td><input type="Text" name="" value="<?php echo $OperatingSystemVersion; ?>" size="30" maxlength="30"></td>
<td><input type="Text" name="" value="<?php echo $lastLogon1; ?>" size="20" maxlength="15"></td>
<td><input type="Text" name="" value="<?php echo $lastLogoff; ?>" size="20" maxlength="15"></td>
<td><input type="Text" name="" value="<?php echo $memberOf; ?>" size="60" maxlength="60"></td>
<td><input type="Submit" name="LogIn" value="aendern"></td>
<td><input type="reset"></td>
</tr>
</form></tr>
<?php
......... geht noch Weiter!!
Kommentar