refactoring
This commit is contained in:
parent
8629b5d867
commit
f1decc1f4c
|
@ -239,7 +239,7 @@ if (isset($_POST['delete'])) {
|
||||||
if (!$stopprocessing) {
|
if (!$stopprocessing) {
|
||||||
// modify attributes
|
// modify attributes
|
||||||
if (isset($attributes[$dn]['modify']) && !$stopprocessing) {
|
if (isset($attributes[$dn]['modify']) && !$stopprocessing) {
|
||||||
$success = @ldap_mod_replace($_SESSION['ldap']->server(), $dn, $attributes[$dn]['modify']);
|
$success = ldap_mod_replace($_SESSION['ldap']->server(), $dn, $attributes[$dn]['modify']);
|
||||||
if (!$success) {
|
if (!$success) {
|
||||||
$errors[] = array ('ERROR', sprintf(_('Was unable to modify attributes from DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server()));
|
$errors[] = array ('ERROR', sprintf(_('Was unable to modify attributes from DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server()));
|
||||||
$stopprocessing = true;
|
$stopprocessing = true;
|
||||||
|
@ -248,7 +248,7 @@ if (isset($_POST['delete'])) {
|
||||||
}
|
}
|
||||||
// add attributes
|
// add attributes
|
||||||
if (isset($attributes[$dn]['add']) && !$stopprocessing) {
|
if (isset($attributes[$dn]['add']) && !$stopprocessing) {
|
||||||
$success = @ldap_mod_add($_SESSION['ldap']->server(), $dn, $attributes[$dn]['add']);
|
$success = ldap_mod_add($_SESSION['ldap']->server(), $dn, $attributes[$dn]['add']);
|
||||||
if (!$success) {
|
if (!$success) {
|
||||||
$errors[] = array ('ERROR', sprintf(_('Was unable to add attributes to DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server()));
|
$errors[] = array ('ERROR', sprintf(_('Was unable to add attributes to DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server()));
|
||||||
$stopprocessing = true;
|
$stopprocessing = true;
|
||||||
|
@ -257,7 +257,7 @@ if (isset($_POST['delete'])) {
|
||||||
}
|
}
|
||||||
// remove attributes
|
// remove attributes
|
||||||
if (isset($attributes[$dn]['remove']) && !$stopprocessing) {
|
if (isset($attributes[$dn]['remove']) && !$stopprocessing) {
|
||||||
$success = @ldap_mod_del($_SESSION['ldap']->server(), $dn, $attributes[$dn]['remove']);
|
$success = ldap_mod_del($_SESSION['ldap']->server(), $dn, $attributes[$dn]['remove']);
|
||||||
if (!$success) {
|
if (!$success) {
|
||||||
$errors[] = array ('ERROR', sprintf(_('Was unable to remove attributes from DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server()));
|
$errors[] = array ('ERROR', sprintf(_('Was unable to remove attributes from DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server()));
|
||||||
$stopprocessing = true;
|
$stopprocessing = true;
|
||||||
|
|
|
@ -48,7 +48,7 @@ if (!empty($_GET['selfService']) && ($_GET['selfService'] === '1')) {
|
||||||
if (strtolower(session_module_name()) == 'files') {
|
if (strtolower(session_module_name()) == 'files') {
|
||||||
session_save_path("../sess");
|
session_save_path("../sess");
|
||||||
}
|
}
|
||||||
@session_start();
|
session_start();
|
||||||
|
|
||||||
/** status messages */
|
/** status messages */
|
||||||
include_once("../lib/status.inc");
|
include_once("../lib/status.inc");
|
||||||
|
|
|
@ -63,8 +63,8 @@ if (isset($_POST['add_suff']) || isset($_POST['cancel'])) {
|
||||||
// add entries
|
// add entries
|
||||||
foreach ($newSuffixes as $newSuffix) {
|
foreach ($newSuffixes as $newSuffix) {
|
||||||
// check if entry is already present
|
// check if entry is already present
|
||||||
$info = @ldap_read($_SESSION['ldap']->server(), escapeDN($newSuffix), "objectclass=*", array('dn'), 0, 0, 0, LDAP_DEREF_NEVER);
|
$info = ldap_read($_SESSION['ldap']->server(), escapeDN($newSuffix), "objectclass=*", array('dn'), 0, 0, 0, LDAP_DEREF_NEVER);
|
||||||
$res = @ldap_get_entries($_SESSION['ldap']->server(), $info);
|
$res = ldap_get_entries($_SESSION['ldap']->server(), $info);
|
||||||
if ($res) continue;
|
if ($res) continue;
|
||||||
$suff = $newSuffix;
|
$suff = $newSuffix;
|
||||||
// generate DN and attributes
|
// generate DN and attributes
|
||||||
|
@ -106,8 +106,8 @@ if (isset($_POST['add_suff']) || isset($_POST['cancel'])) {
|
||||||
// create missing entries
|
// create missing entries
|
||||||
for ($k = sizeof($subsuffs) - 1; $k >= 0; $k--) {
|
for ($k = sizeof($subsuffs) - 1; $k >= 0; $k--) {
|
||||||
// check if subsuffix is present
|
// check if subsuffix is present
|
||||||
$info = @ldap_read($_SESSION['ldap']->server(), escapeDN($subsuffs[$k]), "objectclass=*", array('dn'), 0, 0, 0, LDAP_DEREF_NEVER);
|
$info = ldap_read($_SESSION['ldap']->server(), escapeDN($subsuffs[$k]), "objectclass=*", array('dn'), 0, 0, 0, LDAP_DEREF_NEVER);
|
||||||
$res = @ldap_get_entries($_SESSION['ldap']->server(), $info);
|
$res = ldap_get_entries($_SESSION['ldap']->server(), $info);
|
||||||
if (!$res) {
|
if (!$res) {
|
||||||
$suffarray = explode(",", $subsuffs[$k]);
|
$suffarray = explode(",", $subsuffs[$k]);
|
||||||
$headarray = explode("=", $suffarray[0]);
|
$headarray = explode("=", $suffarray[0]);
|
||||||
|
|
|
@ -604,9 +604,9 @@ if(!empty($_POST['checklogin'])) {
|
||||||
$searchError = _('Cannot connect to specified LDAP server. Please try again.') . ' ' . getDefaultLDAPErrorString($searchLDAP->server());
|
$searchError = _('Cannot connect to specified LDAP server. Please try again.') . ' ' . getDefaultLDAPErrorString($searchLDAP->server());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$searchResult = @ldap_search($searchLDAP->server(), $_SESSION['config']->getLoginSearchSuffix(), $searchFilter, array('dn'), 0, 0, 0, LDAP_DEREF_NEVER);
|
$searchResult = ldap_search($searchLDAP->server(), $_SESSION['config']->getLoginSearchSuffix(), $searchFilter, array('dn'), 0, 0, 0, LDAP_DEREF_NEVER);
|
||||||
if ($searchResult) {
|
if ($searchResult) {
|
||||||
$searchInfo = @ldap_get_entries($searchLDAP->server(), $searchResult);
|
$searchInfo = ldap_get_entries($searchLDAP->server(), $searchResult);
|
||||||
if ($searchInfo) {
|
if ($searchInfo) {
|
||||||
cleanLDAPResult($searchInfo);
|
cleanLDAPResult($searchInfo);
|
||||||
if (sizeof($searchInfo) == 0) {
|
if (sizeof($searchInfo) == 0) {
|
||||||
|
|
|
@ -51,7 +51,9 @@ if (isset($_SESSION['loggedIn']) || ($_SESSION['loggedIn'] === true)) {
|
||||||
logNewMessage(LOG_NOTICE, 'User ' . $ldapUser[0] . ' logged off.');
|
logNewMessage(LOG_NOTICE, 'User ' . $ldapUser[0] . ' logged off.');
|
||||||
|
|
||||||
// close LDAP connection
|
// close LDAP connection
|
||||||
@$_SESSION["ldap"]->destroy();
|
if (!empty($_SESSION["ldap"])) {
|
||||||
|
$_SESSION["ldap"]->destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setlanguage();
|
setlanguage();
|
||||||
|
|
|
@ -50,8 +50,8 @@ $new_suffs = array();
|
||||||
$typeManager = new \LAM\TYPES\TypeManager();
|
$typeManager = new \LAM\TYPES\TypeManager();
|
||||||
$types = $typeManager->getConfiguredTypes();
|
$types = $typeManager->getConfiguredTypes();
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
$info = @ldap_read($_SESSION['ldap']->server(), escapeDN($type->getSuffix()), "(objectClass=*)", array('objectClass'), 0, 0, 0, LDAP_DEREF_NEVER);
|
$info = ldap_read($_SESSION['ldap']->server(), escapeDN($type->getSuffix()), "(objectClass=*)", array('objectClass'), 0, 0, 0, LDAP_DEREF_NEVER);
|
||||||
$res = @ldap_get_entries($_SESSION['ldap']->server(), $info);
|
$res = ldap_get_entries($_SESSION['ldap']->server(), $info);
|
||||||
if (!$res && !in_array($type->getSuffix(), $new_suffs)) {
|
if (!$res && !in_array($type->getSuffix(), $new_suffs)) {
|
||||||
$new_suffs[] = $type->getSuffix();
|
$new_suffs[] = $type->getSuffix();
|
||||||
}
|
}
|
||||||
|
|
|
@ -516,7 +516,7 @@ function doModify() {
|
||||||
$success = false;
|
$success = false;
|
||||||
switch ($opType) {
|
switch ($opType) {
|
||||||
case ADD:
|
case ADD:
|
||||||
$success = @ldap_mod_add($_SESSION['ldap']->server(), $dn, array($attr => array($val)));
|
$success = ldap_mod_add($_SESSION['ldap']->server(), $dn, array($attr => array($val)));
|
||||||
break;
|
break;
|
||||||
case DEL:
|
case DEL:
|
||||||
if (empty($val)) {
|
if (empty($val)) {
|
||||||
|
|
|
@ -103,7 +103,7 @@ if (isset($_POST['createOU']) || isset($_POST['deleteOU'])) {
|
||||||
}
|
}
|
||||||
// delete ou, user was sure
|
// delete ou, user was sure
|
||||||
elseif (isset($_POST['deleteOU']) && isset($_POST['sure'])) {
|
elseif (isset($_POST['deleteOU']) && isset($_POST['sure'])) {
|
||||||
$ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['deletename']);
|
$ret = ldap_delete($_SESSION['ldap']->server(), $_POST['deletename']);
|
||||||
if ($ret) {
|
if ($ret) {
|
||||||
$message = _("OU deleted successfully.");
|
$message = _("OU deleted successfully.");
|
||||||
}
|
}
|
||||||
|
@ -114,8 +114,8 @@ if (isset($_POST['createOU']) || isset($_POST['deleteOU'])) {
|
||||||
// ask if user is sure to delete
|
// ask if user is sure to delete
|
||||||
elseif (isset($_POST['deleteOU'])) {
|
elseif (isset($_POST['deleteOU'])) {
|
||||||
// check for sub entries
|
// check for sub entries
|
||||||
$sr = @ldap_list($_SESSION['ldap']->server(), $_POST['deleteableOU'], "ObjectClass=*", array(""));
|
$sr = ldap_list($_SESSION['ldap']->server(), $_POST['deleteableOU'], "ObjectClass=*", array(""));
|
||||||
$info = @ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
$info = ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
||||||
if ($sr && $info['count'] == 0) {
|
if ($sr && $info['count'] == 0) {
|
||||||
// print header
|
// print header
|
||||||
include 'main_header.php';
|
include 'main_header.php';
|
||||||
|
|
|
@ -50,9 +50,9 @@ $vendorname = '';
|
||||||
$vendorversion = '';
|
$vendorversion = '';
|
||||||
$dynamicSubtrees = '';
|
$dynamicSubtrees = '';
|
||||||
|
|
||||||
$result = @ldap_read($_SESSION['ldap']->server(), '', 'objectclass=*', array('+', '*', 'subschemasubentry'), 0, 0, 0, LDAP_DEREF_NEVER);
|
$result = ldap_read($_SESSION['ldap']->server(), '', 'objectclass=*', array('+', '*', 'subschemasubentry'), 0, 0, 0, LDAP_DEREF_NEVER);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$info = @ldap_get_entries($_SESSION['ldap']->server(), $result);
|
$info = ldap_get_entries($_SESSION['ldap']->server(), $result);
|
||||||
if ($info) {
|
if ($info) {
|
||||||
$info = $info[0];
|
$info = $info[0];
|
||||||
foreach ($info as $key => $value) {
|
foreach ($info as $key => $value) {
|
||||||
|
|
Loading…
Reference in New Issue