added schema browser

This commit is contained in:
Roland Gruber 2005-01-30 15:39:01 +00:00
parent 2b751c5d2a
commit ac5869b658
6 changed files with 2566 additions and 0 deletions

View File

@ -12,6 +12,8 @@
- new plugin for managing MAC addresses (RFE 926017) - new plugin for managing MAC addresses (RFE 926017)
- new plugin for managing NIS mail aliases (RFE 1050036) - new plugin for managing NIS mail aliases (RFE 1050036)
- new plugin for managing mail routing with inetLocalMailRecipient (RFE 1092137) - new plugin for managing mail routing with inetLocalMailRecipient (RFE 1092137)
- added schema browser
26.01.2005 0.4.8 26.01.2005 0.4.8
- allow "%" at the beginning of Samba home/profile path (1107998) - allow "%" at the beginning of Samba home/profile path (1107998)

View File

@ -32,6 +32,8 @@ $Id$
include_once("config.inc"); include_once("config.inc");
/** Encryption functions */ /** Encryption functions */
include_once("blowfish.inc"); include_once("blowfish.inc");
/** LDAP schema */
include_once("schema.inc");
/** /**
* Converts a HEX string to a binary value * Converts a HEX string to a binary value
@ -126,6 +128,11 @@ class Ldap{
if (! $this->objectClasses) { if (! $this->objectClasses) {
$this->updateClasses(); $this->updateClasses();
$this->updateCapabilities(); $this->updateCapabilities();
// update schema
get_schema_objectclasses();
get_schema_attributes();
get_schema_matching_rules();
get_schema_syntaxes();
} }
// return success number // return success number
return ldap_errno($this->server); return ldap_errno($this->server);

2018
lam/lib/schema.inc Normal file

File diff suppressed because it is too large Load Diff

View File

@ -509,3 +509,87 @@ select.useredit-bright {
background-color:#CCCCFF; background-color:#CCCCFF;
} }
table.schema_oclasses {
border-left: 1px solid black;
border-right: 1px solid black;
border-bottom: 1px solid black;
border-top: 0;
margin-bottom: 10px;
background-color: #eee;
}
table.schema_oclasses td {
vertical-align: top;
text-align: left;
padding-left: 5px;
}
table.schema_attr th {
background-color: #016;
padding: 5px;
color: white;
font-weight: bold;
font-size: 125%;
}
table.schema_attr td {
padding: 5px;
vertical-align: top;
}
table.schema_attr tr.even {
background-color: #eee;
}
table.schema_attr tr.odd {
background-color: #ccc;
}
table.schema_attr tr.highlight{
background-color: #bcd;
font-weight: Bold;
}
ul.schema {
margin: 5px;
margin-left: 0px;
padding-left: 20px;
}
ul.schema li {
margin-left: 0px;
padding-left: 0px;
}
ul.schema li small {
font-size: 75%;
color: #777;
}
ul.schema li small a {
color: #77c;
}
h4.schema_oclass {
background: #016;
padding: 5px;
margin: 0px;
margin-top: 8px;
font-weight: normal;
border: 1px solid black;
font-size: 140%;
color: white;
}
h4.schema_oclass_sub {
background: #dde;
border: 1px solid black;
border-top: 0px;
font-weight: normal;
margin: 0px;
padding: 2px;
padding-left: 5px;
font-size: 80%;
}

View File

@ -0,0 +1,448 @@
<?php
/*
$Id$
Copyright (C) 2004 David Smith
modified to fit for LDAP Account Manager 2005 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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* schema.php
* Displays the schema for the specified server_id
*
* Variables that come in as GET vars:
* - server_id
* - view (optional: can be 'attr' or empty. If 'attr', show that attribute)
* - attr (optional)
*/
/** access to LDAP server */
include_once("../../lib/ldap.inc");
/** access to configuration options */
include_once("../../lib/config.inc");
/** schema functions */
require_once("../../lib/schema.inc");
// start session
session_save_path("../../sess");
@session_start();
setlanguage();
echo $_SESSION['header'];
echo "<title>LDAP Account Manager</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
echo "</head>\n";
$view = isset( $_GET['view'] ) ? $_GET['view'] : 'objectClasses';
$viewvalue = isset( $_GET['viewvalue'] ) ? $_GET['viewvalue'] : null;
if( trim( $viewvalue ) == "" )
$viewvalue = null;
if( ! is_null( $viewvalue ) )
$viewed = false;
?>
<body>
<br />
<center><big>
<?php echo ( $view=='objectClasses' ?
_('Object classes') :
'<a href="?view=objectClasses">' . _('Object classes').'</a>' ); ?>
|
<?php echo ( $view=='attributes' ?
_('Attribute types'):
'<a href="?view=attributes">' . _('Attribute types').'</a>' ); ?>
|
<?php echo ( $view=='syntaxes' ?
_('Syntaxes') :
'<a href="?view=syntaxes">' . _('Syntaxes').'</a>' ); ?>
|
<?php echo ( $view=='matching_rules' ?
_('Matching rules') :
'<a href="?view=matching_rules">' . _('Matching rules').'</a>' ); ?>
</big></center>
<br />
<?php flush(); ?>
<?php
if( $view == 'syntaxes' ) {
$highlight_oid = isset( $_GET['highlight_oid'] ) ? $_GET['highlight_oid'] : false;
echo "\n\n<table class=\"schema_attr\" width=\"100%\">\n";
echo "<tr><th>" . _('Syntax OID') . "</th><th>" . _('Description') . "</th></tr>\n";
flush();
$counter=1;
$schema_syntaxes = get_schema_syntaxes(null);
if( ! $schema_syntaxes ) StatusMessage("ERROR", _("Unable to retrieve schema!"), "");
foreach( $schema_syntaxes as $syntax ) {
$counter++;
$oid = htmlspecialchars( $syntax->getOID() );
$desc = htmlspecialchars( $syntax->getDescription() );
if( $highlight_oid && $highlight_oid == $oid )
echo "<tr class=\"highlight\">";
else
echo "<tr class=\"" . ($counter%2==0?'even':'odd'). "\">";
echo "<td><a name=\"$oid\">$oid</a></td><td>$desc</td></tr>\n\n";
}
echo "</table>\n";
} elseif( $view == 'attributes' ) {
flush();
$schema_attrs = get_schema_attributes(null);
$schema_object_classes = get_schema_objectclasses(null);
if( ! $schema_attrs || ! $schema_object_classes )
StatusMessage("ERROR", _("Unable to retrieve schema!"), "");
?>
<small><?php echo _('Jump to an attribute type'); ?>:</small>
<form action="schema.php" method="get"><input type="hidden" name="view" value="<?php echo $view; ?>" />
<select name="viewvalue" onChange="submit()">
<option value=""> - all -</option>
<?php foreach( $schema_attrs as $attr ) {
echo( '<option value="'
.$attr->getName()
.'" '
.( 0 == strcasecmp( $attr->getName(), $viewvalue ) ? ' selected ' : '' )
.'>'
. $attr->getName()
.'</option>' . "\n" );
} ?>
</select><input type="submit" value="<?php echo _('Go'); ?>" /></form>
<br />
<table class="schema_attr" width="100%">
<?php
foreach( $schema_attrs as $attr ) {
if ( is_null( $viewvalue ) || 0 == strcasecmp( $viewvalue, $attr->getName() ) ) {
if( ! is_null( $viewvalue ) )
$viewed = true;
flush();
echo "<tr><th colspan=\"2\">" . $attr->getName() . "</th></tr>\n\n";
$counter = 0;
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
echo "<td>"._('Description')."</td>\n";
echo "<td>" . ( $attr->getDescription() == null ? '('._('No description').')' : $attr->getDescription() ). "</td>\n";
echo "</tr>\n\n";
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
echo "<td><acronym title=\"Object Identier\">"._('OID')."</acronym></td>\n";
echo "<td>" . $attr->getOID() . "</td>\n";
echo "</tr>\n\n";
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
echo '<td>'._('Obsolete')."?</td>\n";
echo "<td>" . ( $attr->getIsObsolete() ? '<b>' . _('Yes') . '</b>' : _('No') ) . "</td>\n";
echo "</tr>\n\n";
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
echo "<td>"._('Inherits from')."</td>\n";
echo "<td>";
if( $attr->getSupAttribute()==null )
echo '('._('none').')';
else
echo "<a href=\"?view=$view&amp;viewvalue=" . strtolower( $attr->getSupAttribute() ) . "\">" . $attr->getSupAttribute() . "</a></td>\n";
echo "</tr>\n\n";
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
echo "<td>"._('Equality')."</td>\n";
echo "<td>" . ( $attr->getEquality() == null ? '('._('not specified').')' : "<a href=\"?view=matching_rules&amp;viewvalue=".$attr->getEquality()."\">".$attr->getEquality()."</a>" ) . "</td>\n";
echo "</tr>\n\n";
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
echo "<td>"._('Ordering')."</td>\n";
echo "<td>" . ( $attr->getOrdering()==null? '('._('not specified').')' : $attr->getOrdering() ) . "</td>\n";
echo "</tr>\n\n";
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
echo "<td>"._('Substring Rule')."</td>\n";
echo "<td>" . ( $attr->getSubstr()==null? '('._('not specified').')' : $attr->getSubstr() ) . "</td>\n";
echo "</tr>\n\n";
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
echo "<td>"._('Syntax')."</td>\n";
echo "<td>";
if( null != $attr->getType() ) {
echo "<a href=\"?view=syntaxes&amp;highlight_oid=";
echo $attr->getSyntaxOID() . "#" . $attr->getSyntaxOID();
echo "\">" . $attr->getType() . " (" . $attr->getSyntaxOID() . ")</a>";
} else {
echo $attr->getSyntaxOID();
}
echo "</td>\n";
echo "</tr>\n\n";
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
echo "<td>"._('Single valued')."</td>\n";
echo "<td>" . ( $attr->getIsSingleValue() ? _('Yes') : _('No') ) . "</td>\n";
echo "</tr>\n\n";
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
echo "<td>"._('Collective')."?</td>\n";
echo "<td>" . ( $attr->getIsCollective() ? _('Yes') : _('No') ) . "</td>\n";
echo "</tr>\n\n";
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
echo "<td>"._('User modification')."</td>\n";
echo "<td>" . ( $attr->getIsNoUserModification() ? _('No') : _('Yes') ) . "</td>\n";
echo "</tr>\n\n";
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
echo "<td>"._('Usage')."</td>\n";
echo "<td>" . ( $attr->getUsage() ? $attr->getUsage() : '('._('not specified').')' ) . "</td>\n";
echo "</tr>\n\n";
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
echo "<td>"._('Maximum length')."</td>\n";
echo "<td>";
if ( $attr->getMaxLength() === null ) { echo '('._('not applicable').')';}
else {
echo number_format( $attr->getMaxLength() ) ." ";
if ( $attr->getMaxLength()>1) {echo _('characters');}
else { echo _('character') ;}
}
echo "</td>\n";
echo "</tr>\n\n";
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
echo "<td>"._('Aliases')."</td>\n";
echo "<td>";
if( count( $attr->getAliases() ) == 0 )
echo '('._('none').')';
else
foreach( $attr->getAliases() as $alias_attr_name )
echo "<a href=\"?view=attributes&amp;viewvalue=" . $alias_attr_name. "\">$alias_attr_name</a> ";
echo "</td>";
echo "</tr>\n\n";
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
echo "<td>"._('Used by object classes')."</td>\n";
echo "<td>";
if( count( $attr->getUsedInObjectClasses() ) == 0 )
echo '('._('none').')';
else
foreach( $attr->getUsedInObjectClasses() as $used_in_oclass)
echo "<a href=\"?view=objectClasses&amp;viewvalue=" .
$used_in_oclass. "\">$used_in_oclass</a> ";
echo "</td>";
echo "</tr>\n\n";
flush();
}
}
echo "</table>\n";
} elseif( $view == 'matching_rules' ) {
$schema_matching_rules = get_schema_matching_rules(null);
echo '<small>' . _('Jump to a matching rule').'</small><br />';
echo '<form action="schema.php" method="get">';
echo '<input type="hidden" name="view" value="matching_rules" />';
echo '<select name="viewvalue" onChange="submit()">';
echo '<option value=""> - all -</option>';
foreach( $schema_matching_rules as $rule ) {
echo '<option value="'.$rule->getName().'"'.($rule->getName()==$viewvalue? ' selected ': '').'>'.$rule->getName().'</option>';
}
echo '</select>';
echo '<input type="submit" value="'._('Go').'" />';
echo '</form>';
echo "\n\n<table class=\"schema_attr\" width=\"100%\">\n";
echo "<tr><th>" . _('Matching rule OID') . "</th><th>" . _('Name') . "</th><th>"._('Used by attributes')."</th></tr>\n";
flush();
$counter=1;
$schema_matching_rules = get_schema_matching_rules(null);
if( ! $schema_matching_rules ) StatusMessage("ERROR", _("Unable to retrieve schema!"), "");
foreach( $schema_matching_rules as $rule ) {
$counter++;
$oid = htmlspecialchars( $rule->getOID() );
$desc = htmlspecialchars( $rule->getName() );
if ( $viewvalue==null || $viewvalue==($rule->getName() )) {
if( ! is_null( $viewvalue ) )
$viewed = true;
if( null != $rule->getDescription() )
$desc .= ' (' . $rule->getDescription() . ')';
if( true === $rule->getIsObsolete() )
$desc .= ' <span style="color:red">' . _('Obsolete') . '</span>';
echo "<tr class=\"" . ($counter%2==0?'even':'odd'). "\">";
echo "<td>$oid</td>";
echo "<td>$desc</td>";
echo "<td>";
if( count( $rule->getUsedByAttrs() ) == 0 ) {
echo "<center>(" . _('none') . ")</center><br /><br />\n";
} else {
echo "<table><tr><td style=\"text-align: right\"><form action=\"schema.php\" method=\"get\">";
echo "<input type=\"hidden\" name=\"view\" value=\"attributes\" />";
echo "<select style=\"width: 150px; color:black; background-color: #eee\" size=\"4\" name=\"viewvalue\">\n";
foreach( $rule->getUsedByAttrs() as $attr )
echo "<option>$attr</option>\n";
echo "</select><br /><input type=\"submit\" value=\""._('Go')."\" /></form></td></tr></table>\n";
}
echo "</td></tr>\n";
}
}
echo "</table>\n";
} elseif( $view == 'objectClasses' ) {
flush();
$schema_oclasses = get_schema_objectclasses(null);
if( ! $schema_oclasses ) StatusMessage("ERROR", _("Unable to retrieve schema!"), "");
?>
<small><?php echo _('Jump to an object class'); ?>:</small>
<form action="schema.php" method="get"><input type="hidden" name="view" value="<?php echo $view; ?>" />
<select name="viewvalue"
onChange="submit()">
<option value=""> - all - </option>
<?php foreach( $schema_oclasses as $name => $oclass ) {
echo '<option value="'
.$oclass->getName()
.'"'
. ( 0 == strcasecmp( $oclass->getName(), $viewvalue ) ? ' selected ':'')
.'>'.$oclass->getName()
.'</option>';
} ?>
</select><input type="submit" value="<?php echo _('Go'); ?>" />
</form>
<?php flush(); ?>
<?php foreach( $schema_oclasses as $name => $oclass ) {
foreach( $oclass->getSupClasses() as $parent_name ) {
$parent_name = $parent_name;
if( isset( $schema_oclasses[ $parent_name ] ) ) {
$schema_oclasses[ $parent_name ]->addChildObjectClass( $oclass->getName() );
}
}
} ?>
<br />
<?php foreach( $schema_oclasses as $name => $oclass ) {
if ( $viewvalue==null || 0 == strcasecmp( $viewvalue, $oclass->getName() ) ){
if( ! is_null( $viewvalue ) )
$viewed = true;
?>
<h4 class="schema_oclass"><?php echo $oclass->getName(); ?></h4>
<h4 class="schema_oclass_sub"><?php echo _('OID'); ?>: <b><?php echo $oclass->getOID(); ?></b></h4>
<?php if( $oclass->getDescription() ) { ?>
<h4 class="schema_oclass_sub"><?php echo _('Description'); ?>: <b><?php echo $oclass->getDescription(); ?></b></h4>
<?php } ?>
<h4 class="schema_oclass_sub"><?php echo _('Type'); ?>: <b><?php echo $oclass->getType(); ?></b></h4>
<?php if( $oclass->getIsObsolete() == true ) { ?>
<h4 class="schema_oclass_sub"><?php echo _('This object class is obsolete.'); ?></h4>
<?php } ?>
<h4 class="schema_oclass_sub"><?php echo _('Inherits from'); ?>: <b><?php
if( count( $oclass->getSupClasses() ) == 0 )
echo "(" . _('none') . ")";
else
foreach( $oclass->getSupClasses() as $i => $object_class ) {
echo '<a title="' . _('Jump to an object class') . ' "
href="?view='.$view.'&amp;viewvalue='.htmlspecialchars( $object_class ) ;
echo '">' . htmlspecialchars( $object_class ) . '</a>';
if( $i < count( $oclass->getSupClasses() ) - 1 )
echo ', ';
}
?></b></h4>
<h4 class="schema_oclass_sub"><?php echo _('Parent to'); ?>: <b><?php
if( 0 == strcasecmp( $oclass->getName(), 'top' ) )
echo "(<a href=\"schema.php?view=objectClasses\">all</a>)";
elseif( count( $oclass->getChildObjectClasses() ) == 0 )
echo "(" . _('none') . ")";
else
foreach( $oclass->getChildObjectClasses() as $i => $object_class ) {
echo '<a title="' . _('Jump to an object class') . ' "
href="?view='.$view.'&amp;viewvalue='.htmlspecialchars( $object_class ) ;
echo '">' . htmlspecialchars( $object_class ) . '</a>';
if( $i < count( $oclass->getChildObjectClasses() ) - 1 )
echo ', ';
}
?></b></h4>
<table width="100%" class="schema_oclasses">
<tr>
<th width="50%"><b><?php echo _('Required attributes'); ?></b></th>
<th width="50%"><b><?php echo _('Optional attributes'); ?></b></th>
</tr>
<tr>
<td>
<?php if( count( $oclass->getMustAttrs($schema_oclasses) ) > 0 ) {
echo '<ul class="schema">';
foreach( $oclass->getMustAttrs($schema_oclasses) as $attr ) {
echo "<li><a href=\"?view=attributes&amp;viewvalue=";
echo rawurlencode( $attr->getName() ). "\">" . htmlspecialchars($attr->getName());
echo "</a>";
if( $attr->getSource() != $oclass->getName() )
{
echo "<br /><small>&nbsp;&nbsp;("._('Inherited from')." ";
echo "<a href=\"?view=objectClasses&amp;viewvalue=" . $attr->getSource() . "\">" . $attr->getSource() . "</a>";
echo ")</small>";
}
echo "</li>\n";
}
echo "</ul>";
} else
echo "<center>(" . _('none') . ")</center>\n";
?>
</td>
<td width="50%">
<?php
if( count( $oclass->getMayAttrs($schema_oclasses) ) > 0 ) {
echo '<ul class="schema">';
foreach( $oclass->getMayAttrs($schema_oclasses) as $attr ) {
echo "<li><a href=\"?view=attributes&amp;viewvalue=";
echo rawurlencode( $attr->getName() ) . "\">" . htmlspecialchars($attr->getName() );
echo "</a>\n";
if( $attr->getSource() != $oclass->getName() )
{
echo "<br /><small>&nbsp;&nbsp; ("._('Inherited from')." ";
echo "<a href=\"?view=objectClasses&amp;viewvalue=" . $attr->getSource() . "\">" . $attr->getSource() . "</a>";
echo ")</small>";
}
echo "</li>";
}
echo "</ul>";
}
else
echo "<center>(" . _('none') . ")</center>\n";
?>
</td>
</tr>
</table>
<?php } } /* End foreach objectClass */ ?>
<?php } /* End else (displaying objectClasses */ ?>
<?php if( ! is_null( $viewvalue ) && ! $viewed )
StatusMessage( sprintf( _('No such schema item: "%s"'), htmlspecialchars( $viewvalue ) ) );
?>
</body>
</html>

View File

@ -85,6 +85,13 @@ $tools[] = array(
"link" => "pdfedit/pdfmain.php" "link" => "pdfedit/pdfmain.php"
); );
// schema browser
$tools[] = array(
"name" => _("Schema browser"),
"description" => _("Here you can browse LDAP object classes and attributes."),
"link" => "schema/schema.php"
);
echo "<p>&nbsp;</p>\n"; echo "<p>&nbsp;</p>\n";
// print tools table // print tools table