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
- Login can show display name instead of server URL
- 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

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/namedObject.inc
* lib/modules/nisObject.inc
* lib/modules/nsview.inc
* lib/modules/passwordSelfReset.inc
* lib/modules/oracleService.inc
* lib/modules/organizationalRole*.inc
@ -48,6 +49,7 @@ time.
* lib/types/automountType.inc
* lib/types/gon.inc
* lib/types/nisObjectType.inc
* lib/types/nsview.inc
* lib/types/oracleContextType.inc
* lib/types/ppolicyType.inc
* lib/types/sudo.inc

View File

@ -3,7 +3,7 @@
$Id$
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
it under the terms of the GNU General Public License as published by
@ -1222,6 +1222,15 @@ abstract class baseModule {
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.
*

View File

@ -3,7 +3,7 @@
$Id$
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
it under the terms of the GNU General Public License as published by
@ -1971,6 +1971,20 @@ class accountContainer {
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.
*

View File

@ -3,7 +3,7 @@ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
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
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-dark { background-color:#80e0e1 !important; }
.nsviewType-border { border-color:#af8800; }
.nsviewType-bright { background:#fff3c8 !important; }
.nsviewType-dark { background-color:#ffe27f !important; }
/** responsive styles */
.row {

View File

@ -4,7 +4,7 @@
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
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
it under the terms of the GNU General Public License as published by
@ -103,10 +103,13 @@ if (isset($_GET['type']) && isset($_SESSION['delete_dn'])) {
echo "<tr>\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";
$_SESSION['account']->load_account($_SESSION['delete_dn'][$i]);
if (!$_SESSION['account']->hasOnlyVirtualChildren()) {
$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 "</table>\n";
@ -255,7 +258,8 @@ if (isset($_POST['delete'])) {
}
}
if (!$stopprocessing) {
$messages = deleteDN($_SESSION['delete_dn'][$m]);
$recursive = !$_SESSION['account']->hasOnlyVirtualChildren();
$messages = deleteDN($_SESSION['delete_dn'][$m], $recursive);
$errors = array_merge($errors, $messages);
if (sizeof($errors) > 0) {
$stopprocessing = true;
@ -328,21 +332,23 @@ function getChildCount($dn) {
* Deletes a DN and all child entries.
*
* @param string $dn DN to delete
* @param boolean $recursive recursive delete also child entries
* @return array error messages
*/
function deleteDN($dn) {
function deleteDN($dn, $recursive) {
$errors = array();
if (($dn == null) || ($dn == '')) {
$errors[] = array('ERROR', _('Entry does not exist'));
return $errors;
}
if ($recursive) {
$sr = @ldap_list($_SESSION['ldap']->server(), $dn, 'objectClass=*', array('dn'), 0, 0, 0, LDAP_DEREF_NEVER);
if ($sr) {
$entries = ldap_get_entries($_SESSION['ldap']->server(), $sr);
cleanLDAPResult($entries);
for ($i = 0; $i < sizeof($entries); $i++) {
// delete recursively
$subErrors = deleteDN($entries[$i]['dn']);
$subErrors = deleteDN($entries[$i]['dn'], $recursive);
for ($e = 0; $e < sizeof($subErrors); $e++) $errors[] = $subErrors[$e];
}
}
@ -350,6 +356,7 @@ function deleteDN($dn) {
$errors[] = array ('ERROR', sprintf(_('Was unable to delete DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server()));
return $errors;
}
}
// delete parent DN
$success = @ldap_delete($_SESSION['ldap']->server(), $dn);
$ldapUser = $_SESSION['ldap']->decrypt_login();