support for LDAP views based on nsview

This commit is contained in:
Roland Gruber 2016-01-06 15:05:52 +00:00
parent a3a5cd0dc5
commit 3b20a34774
8 changed files with 70 additions and 23 deletions

View File

@ -3,6 +3,10 @@ March 2016 5.3
- Windows: support management of fax number - Windows: support management of fax number
- Login can show display name instead of server URL - Login can show display name instead of server URL
- Personal/Unix: support K5KEY hash type for smbk5pwd - Personal/Unix: support K5KEY hash type for smbk5pwd
- fixed bugs:
-> autoload errors in tree view
- LAM Pro:
-> Support for LDAP views based on nsview object class
15.12.2015 5.2 15.12.2015 5.2

View File

@ -0,0 +1,6 @@
<pdf type="nsviewType" filename="printLogo.jpg" headline="LDAP Account Manager" foldingmarks="no">
<section name="_nsview_ou">
<entry name="nsview_nsViewFilter" />
<entry name="nsview_description" />
</section>
</pdf>

View File

@ -0,0 +1 @@

View File

@ -26,6 +26,7 @@ time.
* lib/modules/mitKerberosStructural.inc * lib/modules/mitKerberosStructural.inc
* lib/modules/namedObject.inc * lib/modules/namedObject.inc
* lib/modules/nisObject.inc * lib/modules/nisObject.inc
* lib/modules/nsview.inc
* lib/modules/passwordSelfReset.inc * lib/modules/passwordSelfReset.inc
* lib/modules/oracleService.inc * lib/modules/oracleService.inc
* lib/modules/organizationalRole*.inc * lib/modules/organizationalRole*.inc
@ -48,6 +49,7 @@ time.
* lib/types/automountType.inc * lib/types/automountType.inc
* lib/types/gon.inc * lib/types/gon.inc
* lib/types/nisObjectType.inc * lib/types/nisObjectType.inc
* lib/types/nsview.inc
* lib/types/oracleContextType.inc * lib/types/oracleContextType.inc
* lib/types/ppolicyType.inc * lib/types/ppolicyType.inc
* lib/types/sudo.inc * lib/types/sudo.inc

View File

@ -3,7 +3,7 @@
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2015 Roland Gruber Copyright (C) 2003 - 2016 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -1222,6 +1222,15 @@ abstract class baseModule {
return 0; return 0;
} }
/**
* Defines if the LDAP entry has only virtual child entries. This is the case for e.g. LDAP views.
*
* @return boolean has only virtual children
*/
public function hasOnlyVirtualChildren() {
return false;
}
/** /**
* This function processes user input. * This function processes user input.
* *

View File

@ -3,7 +3,7 @@
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2015 Roland Gruber Copyright (C) 2003 - 2016 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -1971,6 +1971,20 @@ class accountContainer {
return $errors; return $errors;
} }
/**
* Defines if the LDAP entry has only virtual child entries. This is the case for e.g. LDAP views.
*
* @return boolean has only virtual children
*/
public function hasOnlyVirtualChildren() {
foreach ($this->module as $module) {
if ($module->hasOnlyVirtualChildren()) {
return true;
}
}
return false;
}
/** /**
* Returns a list of possible PDF entries for this account. * Returns a list of possible PDF entries for this account.
* *

View File

@ -3,7 +3,7 @@ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 Leonhard Walchshaeusl Copyright (C) 2003 Leonhard Walchshaeusl
Copyright (C) 2005 - 2015 Roland Gruber Copyright (C) 2005 - 2016 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -674,6 +674,10 @@ h4.schema_oclass_sub {
.oracleContextType-bright { background:#b6eeff !important; } .oracleContextType-bright { background:#b6eeff !important; }
.oracleContextType-dark { background-color:#80e0e1 !important; } .oracleContextType-dark { background-color:#80e0e1 !important; }
.nsviewType-border { border-color:#af8800; }
.nsviewType-bright { background:#fff3c8 !important; }
.nsviewType-dark { background-color:#ffe27f !important; }
/** responsive styles */ /** responsive styles */
.row { .row {

View File

@ -4,7 +4,7 @@
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2006 Tilo Lutz Copyright (C) 2003 - 2006 Tilo Lutz
Copyright (C) 2007 - 2015 Roland Gruber Copyright (C) 2007 - 2016 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -103,9 +103,12 @@ if (isset($_GET['type']) && isset($_SESSION['delete_dn'])) {
echo "<tr>\n"; echo "<tr>\n";
echo "<td><b>" . _("Account name:") . "</b> " . htmlspecialchars($users[$i]) . "</td>\n"; echo "<td><b>" . _("Account name:") . "</b> " . htmlspecialchars($users[$i]) . "</td>\n";
echo "<td>&nbsp;&nbsp;<b>" . _('DN') . ":</b> " . htmlspecialchars($_SESSION['delete_dn'][$i]) . "</td>\n"; echo "<td>&nbsp;&nbsp;<b>" . _('DN') . ":</b> " . htmlspecialchars($_SESSION['delete_dn'][$i]) . "</td>\n";
$childCount = getChildCount($_SESSION['delete_dn'][$i]); $_SESSION['account']->load_account($_SESSION['delete_dn'][$i]);
if ($childCount > 0) { if (!$_SESSION['account']->hasOnlyVirtualChildren()) {
echo "<td>&nbsp;&nbsp;<b>" . _('Number of child entries') . ":</b> " . $childCount . "</td>\n"; $childCount = getChildCount($_SESSION['delete_dn'][$i]);
if ($childCount > 0) {
echo "<td>&nbsp;&nbsp;<b>" . _('Number of child entries') . ":</b> " . $childCount . "</td>\n";
}
} }
echo "</tr>\n"; echo "</tr>\n";
} }
@ -158,7 +161,7 @@ if (isset($_POST['delete'])) {
echo "<input name=\"type\" type=\"hidden\" value=\"" . $_POST['type'] . "\">\n"; echo "<input name=\"type\" type=\"hidden\" value=\"" . $_POST['type'] . "\">\n";
echo "<div class=\"".$_POST['type']."-bright smallPaddingContent\"><br>\n"; echo "<div class=\"".$_POST['type']."-bright smallPaddingContent\"><br>\n";
echo "<br>\n"; echo "<br>\n";
// Delete dns // Delete dns
$allOk = true; $allOk = true;
$allErrors = array(); $allErrors = array();
@ -255,7 +258,8 @@ if (isset($_POST['delete'])) {
} }
} }
if (!$stopprocessing) { if (!$stopprocessing) {
$messages = deleteDN($_SESSION['delete_dn'][$m]); $recursive = !$_SESSION['account']->hasOnlyVirtualChildren();
$messages = deleteDN($_SESSION['delete_dn'][$m], $recursive);
$errors = array_merge($errors, $messages); $errors = array_merge($errors, $messages);
if (sizeof($errors) > 0) { if (sizeof($errors) > 0) {
$stopprocessing = true; $stopprocessing = true;
@ -273,7 +277,7 @@ if (isset($_POST['delete'])) {
} }
} }
} }
} }
if (!$stopprocessing) { if (!$stopprocessing) {
echo sprintf(_('Deleted DN: %s'), $_SESSION['delete_dn'][$m]) . "<br>\n"; echo sprintf(_('Deleted DN: %s'), $_SESSION['delete_dn'][$m]) . "<br>\n";
foreach ($errors as $error) { foreach ($errors as $error) {
@ -328,27 +332,30 @@ function getChildCount($dn) {
* Deletes a DN and all child entries. * Deletes a DN and all child entries.
* *
* @param string $dn DN to delete * @param string $dn DN to delete
* @param boolean $recursive recursive delete also child entries
* @return array error messages * @return array error messages
*/ */
function deleteDN($dn) { function deleteDN($dn, $recursive) {
$errors = array(); $errors = array();
if (($dn == null) || ($dn == '')) { if (($dn == null) || ($dn == '')) {
$errors[] = array('ERROR', _('Entry does not exist')); $errors[] = array('ERROR', _('Entry does not exist'));
return $errors; return $errors;
} }
$sr = @ldap_list($_SESSION['ldap']->server(), $dn, 'objectClass=*', array('dn'), 0, 0, 0, LDAP_DEREF_NEVER); if ($recursive) {
if ($sr) { $sr = @ldap_list($_SESSION['ldap']->server(), $dn, 'objectClass=*', array('dn'), 0, 0, 0, LDAP_DEREF_NEVER);
$entries = ldap_get_entries($_SESSION['ldap']->server(), $sr); if ($sr) {
cleanLDAPResult($entries); $entries = ldap_get_entries($_SESSION['ldap']->server(), $sr);
for ($i = 0; $i < sizeof($entries); $i++) { cleanLDAPResult($entries);
// delete recursively for ($i = 0; $i < sizeof($entries); $i++) {
$subErrors = deleteDN($entries[$i]['dn']); // delete recursively
for ($e = 0; $e < sizeof($subErrors); $e++) $errors[] = $subErrors[$e]; $subErrors = deleteDN($entries[$i]['dn'], $recursive);
for ($e = 0; $e < sizeof($subErrors); $e++) $errors[] = $subErrors[$e];
}
}
else {
$errors[] = array ('ERROR', sprintf(_('Was unable to delete DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server()));
return $errors;
} }
}
else {
$errors[] = array ('ERROR', sprintf(_('Was unable to delete DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server()));
return $errors;
} }
// delete parent DN // delete parent DN
$success = @ldap_delete($_SESSION['ldap']->server(), $dn); $success = @ldap_delete($_SESSION['ldap']->server(), $dn);