merge with 0_6_dev branch

This commit is contained in:
Roland Gruber 2006-01-01 16:30:05 +00:00
parent d514c6ae16
commit fdfc9f8dca
62 changed files with 3849 additions and 3126 deletions

View File

@ -11,39 +11,9 @@ admins: cn=Manager,dc=my-domain,dc=com
# password to change these preferences via webfrontend # password to change these preferences via webfrontend
passwd: lam passwd: lam
# suffix of users # suffix of tree view
# e.g. ou=People,dc=yourdomain,dc=org # e.g. dc=yourdomain,dc=org
usersuffix: ou=people,dc=my-domain,dc=com treesuffix: dc=yourdomain,dc=org
# suffix of groups
# e.g. ou=Groups,dc=yourdomain,dc=org
groupsuffix: ou=groups,dc=my-domain,dc=com
# suffix of Samba hosts
# e.g. ou=machines,dc=yourdomain,dc=org
hostsuffix: ou=machines,dc=my-domain,dc=com
# suffix of Samba 3 domains
# e.g. ou=domains,dc=yourdomain,dc=org
domainsuffix: ou=domains,dc=my-domain,dc=com
# list of attributes to show in user list
# entries can either be predefined values (e.g. '#cn' or '#uid')
# or individual ones (e.g. 'uid:User ID' or 'host:Host Name')
# values have to be seperated by semicolons
userlistAttributes: #uid;#givenName;#sn;#uidNumber;#gidNumber
# list of attributes to show in group list
# entries can either be predefined values (e.g. '#cn' or '#gidNumber')
# or individual ones (e.g. 'cn:Group Name')
# values have to be seperated by semicolons
grouplistAttributes: #cn;#gidNumber;#memberUID;#description
# list of attributes to show in host list
# entries can either be predefined values (e.g. '#cn' or '#uid')
# or individual ones (e.g. 'cn:Host Name')
# values have to be seperated by semicolons
hostlistAttributes: #cn;#description;#uidNumber;#gidNumber
# maximum number of rows to show in user/group/host lists # maximum number of rows to show in user/group/host lists
maxlistentries: 30 maxlistentries: 30
@ -60,15 +30,6 @@ scriptServer:
# Number of minutes LAM caches LDAP searches. # Number of minutes LAM caches LDAP searches.
cachetimeout: 5 cachetimeout: 5
# List of used user modules
usermodules: shadowAccount,inetOrgPerson,posixAccount,sambaSamAccount
# List of used group modules
groupmodules: posixGroup,sambaGroupMapping
# List of used host modules
hostmodules: account,sambaSamAccount,posixAccount
# Module settings # Module settings
modules: posixAccount_minUID: 10000 modules: posixAccount_minUID: 10000
@ -80,3 +41,23 @@ modules: posixGroup_maxGID: 20000
modules: posixGroup_pwdHash: SSHA modules: posixGroup_pwdHash: SSHA
modules: posixAccount_pwdHash: SSHA modules: posixAccount_pwdHash: SSHA
# List of active account types.
activeTypes: user,group,host,smbDomain
types: suffix_user: ou=People,dc=my-domain,dc=com
types: attr_user: #uid;#givenName;#sn;#uidNumber;#gidNumber
types: modules_user: inetOrgPerson,posixAccount,shadowAccount,sambaSamAccount
types: suffix_group: ou=group,dc=my-domain,dc=com
types: attr_group: #cn;#gidNumber;#memberUID;#description
types: modules_group: posixGroup,sambaGroupMapping
types: suffix_host: ou=machines,dc=my-domain,dc=com
types: attr_host: #cn;#description;#uidNumber;#gidNumber
types: modules_host: account,posixAccount,sambaSamAccount
types: suffix_smbDomain: ou=domains,dc=my-domain,dc=com
types: attr_smbDomain: sambaDomainName:Domain name;sambaSID:Domain SID
types: modules_smbDomain: sambaDomain

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@

View File

@ -90,7 +90,8 @@ browser</a><br>
<br> <br>
<h2>Howtos</h2> <h2>Howtos</h2>
<ul> <ul>
<li><a href="mod_index.htm">Writing account modules</a><br> <li><a href="mod_index.htm">Writing account modules</a></li>
<li><a href="type_index.htm">Defining other account types</a><br>
</li> </li>
</ul> </ul>
<br> <br>

View File

@ -0,0 +1,70 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Type HowTo - Basic concepts</title>
<link rel="stylesheet" type="text/css" href="style/layout.css">
</head>
<body>
<div style="text-align: center;">
<h1>Type HowTo - Basic concepts<br>
</h1>
<br>
<br>
<div style="text-align: left;"><br>
<h2>1. Licensing</h2>
LAM is licensed under the <a href="http://www.gnu.org/licenses/gpl.txt">GNU
General Public License</a>. This means your plugins need a compatible
license.<br>
LAM is distributed with a copy of the GPL license.<br>
<br>
<br>
<h2>2. Naming and position in directory structure</h2>
Type names are usually named after the group of accounts they manage.
However, you can use any name you want, it should be short and
containing only a-z and 0-9. The type name is only shown in the
configuration dialog, on all other pages LAM will show a provided <span
style="font-style: italic;">alias</span> name.<br>
All type modules are stored in <span style="font-weight: bold;">lib/types</span>.
The filename must end with <span style="font-weight: bold;">.inc</span>
and the file must have the same name as its inside class.<br>
<br>
<span style="font-weight: bold; text-decoration: underline;">Example:</span>
Our example module will provide the <span style="font-weight: bold;">class
</span><span style="font-style: italic; font-weight: bold;">smbDomain</span>,
therefore the file will be called <span style="font-weight: bold;">lib/types/</span><span
style="font-style: italic; font-weight: bold;">smbDomain.inc</span>.<span
style="font-style: italic;"></span><br>
<br>
<br>
<h2>3. Defining the class</h2>
All type classes have <span style="font-weight: bold;">baseType</span>
as parent class. This provides common functionality and dummy functions
for all required class functions.<br>
<br>
<span style="font-weight: bold;">Example:</span><br>
<br>
<table style="width: 100%; text-align: left;" class="mod-code"
border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top;">/**<br>
* The account type for Samba domains.<br>
*<br>
* @package types<br>
*/<span style="font-weight: bold;"><br>
class</span> <span style="color: rgb(255, 0, 0);">smbDomain</span><span
style="font-style: italic;"> extends </span><span
style="font-weight: bold;">baseType</span> {<br>
<br>
}<br>
</td>
</tr>
</tbody>
</table>
<br>
<br>
<h2><span style="font-weight: bold;"></span></h2>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,39 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Type HowTo - CSS file</title>
<link rel="stylesheet" type="text/css" href="style/layout.css">
</head>
<body>
<div style="text-align: center;">
<h1>Type HowTo - CSS file</h1>
<br>
<div style="text-align: left;"><br>
Every account type has its own style sheet where it can define colors
and fonts.<br>
<br>
<br>
<h2>1. File name</h2>
The CSS files are saved in <span style="font-weight: bold;">style/</span>.
Your file must be named <span style="font-weight: bold;">type_&lt;your
type&gt;.css</span>.<br>
<br>
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br
style="font-weight: bold; text-decoration: underline;">
<br>
The <span style="font-style: italic;">smbDomain</span> type has the
CSS file <span style="font-weight: bold;">style/type_smbDomain.css</span>.<br>
<br>
<br>
<h2>2. Contents</h2>
Take the type_user.css file as template. It is well documented.<br>
You have to replace all occurrences of "user" with your account type.<br>
<br>
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br
style="font-weight: bold; text-decoration: underline;">
<br>
Take a look at type_user.css and type_smbDomain.css.<br>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,90 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Type HowTo - General type options</title>
<link rel="stylesheet" type="text/css" href="style/layout.css">
</head>
<body>
<div style="text-align: center;">
<h1>Type HowTo - General type options<br>
</h1>
<br>
<br>
<div style="text-align: left;"><br>
<h2>1. Alias name</h2>
The type name is very limited, therefore every type has an <span
style="font-style: italic;">alias name</span>. This <span
style="font-style: italic;">alias name</span> has no limitations and
can be translated. It may contain special characters but make sure that
it does not contain HTML special characters like "&lt;".<br>
<br>
The <span style="font-style: italic;">alias name</span> is specified
with <span style="font-weight: bold;">getAlias()</span><span
style="font-weight: bold;"></span>.<br>
<br>
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br
style="font-weight: bold; text-decoration: underline;">
<br>
Our <span style="font-style: italic;">smbDomain</span> type will get
the alias "Samba domains".<br>
<br>
<table style="width: 100%; text-align: left;" class="mod-code"
border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top;">&nbsp;&nbsp;&nbsp; /**<br>
&nbsp;&nbsp;&nbsp; * Returns the alias name of this account type.<br>
&nbsp;&nbsp;&nbsp; *<br>
&nbsp;&nbsp;&nbsp; * @return string alias name<br>
&nbsp;&nbsp;&nbsp; */<br>
&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span>
<span style="color: rgb(255, 0, 0);">getAlias()</span> {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return _("Samba domains");<br>
&nbsp;&nbsp;&nbsp; }<br>
</td>
</tr>
</tbody>
</table>
<br>
<br>
<h2>2. Description<br>
</h2>
Each type has a description so that the user knows what accounts he can
manage with that type. The description is displayed in the LAM
configuration editor.<br>
<br>
The description is specified with <span style="font-weight: bold;">getDescription()</span><span
style="font-weight: bold;"></span>.<br>
<br>
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br
style="font-weight: bold; text-decoration: underline;">
<br>
Our <span style="font-style: italic;">smbDomain</span> type has the
description "Samba 3 domain entries".<br>
<br>
<table style="width: 100%; text-align: left;" class="mod-code"
border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top;">&nbsp;&nbsp;&nbsp; /**<br>
&nbsp;&nbsp;&nbsp; * Returns the description of this account type.<br>
&nbsp;&nbsp;&nbsp; *<br>
&nbsp;&nbsp;&nbsp; * @return string description<br>
&nbsp;&nbsp;&nbsp; */<br>
&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span>
<span style="color: rgb(255, 0, 0);">getDescription()</span> {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return _("Samba 3 domain
entries");<br>
&nbsp;&nbsp;&nbsp; }<br>
</td>
</tr>
</tbody>
</table>
<br>
<br>
<span style="font-weight: bold;"></span>
<h2><span style="font-weight: bold;"></span></h2>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,31 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Type HowTo - Icon</title>
<link rel="stylesheet" type="text/css" href="style/layout.css">
</head>
<body>
<div style="text-align: center;">
<h1>Type HowTo - Icon</h1>
<br>
<div style="text-align: left;"><br>
You have to provide an icon for your account type. This icon is
displayed in the upper frame next to the link to your account list.<br>
The format of the image must be <span style="font-weight: bold;">PNG</span>
and the size should be between <span style="font-weight: bold;">20x20</span>
and <span style="font-weight: bold;">25x25</span> pixels.<br>
<br>
The file is stored in <span style="font-weight: bold;">graphics/</span>
with the file name <span style="font-weight: bold;">&lt;your
type&gt;.png</span>.<br>
<br>
<br>
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br
style="font-weight: bold; text-decoration: underline;">
<br>
The <span style="font-style: italic;">smbDomain</span> type has the
icon graphics/smbDomain.png.<br>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,36 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>LAM type HowTo</title>
<link rel="stylesheet" type="text/css" href="style/layout.css">
</head>
<body>
<div style="text-align: center;">
<h1>Type HowTo</h1>
<br>
<div style="text-align: left;">If you write new account modules they
may not fit in the existing group of account types (user, group, host,
...). In this case you can easily create a new account type.<br>
This document provides a step-by-step description to build a type
module. The <span style="font-style: italic;">smbDomain</span>
module which handles Samba domains is used as example.<br>
</div>
<br>
<div style="text-align: left;">
<h2>1. Defining the type<br>
</h2>
<h3><a href="type_basics.htm">1. Basic concepts</a><br>
</h3>
<h3><a href="type_general.htm">2. General type options</a></h3>
<h3><a href="type_list.htm">3. Custom list view</a></h3>
<br>
<br>
<h2><a href="type_profile.htm">2. The default profile</a></h2>
<br>
<h2><a href="type_icon.htm">3. List icon</a></h2>
<br>
<h2><a href="type_css.htm">4. Type specific CSS file</a></h2>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,181 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Type HowTo - Custom list view</title>
<link rel="stylesheet" type="text/css" href="style/layout.css">
</head>
<body>
<div style="text-align: center;">
<h1>Type HowTo - Custom list view<br>
</h1>
<br>
<br>
<div style="text-align: left;"><br>
<h2>1. Default list attributes<br>
</h2>
Here you can specify what attributes are shown as default in the list
view.<br>
<br>
The <span style="font-style: italic;">default attributes</span> are
specified
with <span style="font-weight: bold;">getDefaultListAttributes()</span><span
style="font-weight: bold;"></span>.<br>
<br>
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br
style="font-weight: bold; text-decoration: underline;">
<br>
Our <span style="font-style: italic;">smbDomain</span> type will show
the attributes "#sambaDomainName;#sambaSID" by default.<br>
<br>
<table style="width: 100%; text-align: left;" class="mod-code"
border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top;">&nbsp;&nbsp;&nbsp; /**<br>
&nbsp;&nbsp;&nbsp; * Returns the default attribute list for this
account type.<br>
&nbsp;&nbsp;&nbsp; *<br>
&nbsp;&nbsp;&nbsp; * @return string attribute list<br>
&nbsp;&nbsp;&nbsp; */<br>
&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span> <span
style="color: rgb(255, 0, 0);">getDefaultListAttributes()</span> {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return
"#sambaDomainName;#sambaSID";<br>
&nbsp;&nbsp;&nbsp; }<br>
</td>
</tr>
</tbody>
</table>
<br>
<br>
<h2>2. Pretranslated attribute descriptions<br>
</h2>
You can provide translated descriptions for common attributes. This way
the user only specifies the attributes and LAM will show a description
for each language.<br>
<br>
The descriptions are specified with <span style="font-weight: bold;">getListAttributeDescriptions()</span><span
style="font-weight: bold;"></span>.<br>
<br>
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br
style="font-weight: bold; text-decoration: underline;">
<br>
Our <span style="font-style: italic;">smbDomain</span> type has
descriptions for sambaSID and sambaDomainName.<br>
<br>
<table style="width: 100%; text-align: left;" class="mod-code"
border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top;">&nbsp;&nbsp;&nbsp; /**<br>
&nbsp;&nbsp;&nbsp; * Returns a list of attributes which have a
translated description.<br>
&nbsp;&nbsp;&nbsp; * This is used for the head row in the list view.<br>
&nbsp;&nbsp;&nbsp; *<br>
&nbsp;&nbsp;&nbsp; * @return array list of descriptions<br>
&nbsp;&nbsp;&nbsp; */<br>
&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span> <span
style="color: rgb(255, 0, 0);">getListAttributeDescriptions()</span> {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return array(<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "sambaSID"
=&gt; _("Domain SID"),<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
"sambaDomainName" =&gt; _("Domain name")<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; );<br>
&nbsp;&nbsp;&nbsp; }<br>
</td>
</tr>
</tbody>
</table>
<br>
<br>
<br>
<h2>3. Specifying a custom list view</h2>
The default list view has only very generic labels for the buttons and
navigation bar. So you should at least provide some new labels which
fit to your type.<br>
<br>
The class name of your list view is specified with <span
style="font-weight: bold;">getListClassName()</span><span
style="font-weight: bold;"></span>.<br>
<br>
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br
style="font-weight: bold; text-decoration: underline;">
<br>
Our <span style="font-style: italic;">smbDomain</span> type sets the
list view class to <span style="font-style: italic;">lamSmbDomainList</span>.
The list class is defined in the same file as your type class
(smbDomain.inc in this case).<br>
The labels are set in the constructor. Do not forget to call the parent
constructor first.<br>
<br>
If you want to change more than just the labels, take a look at <span
style="font-weight: bold;">lib/lists.inc</span> and <span
style="font-weight: bold;">lib/types/user.inc</span>. When a list is
displayed then the <span style="font-weight: bold;">showPage()</span>
function is called. You can overwrite this function to display a
completly new list or just one of the other functions.<br>
<br>
<table style="width: 100%; text-align: left;" class="mod-code"
border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top;">/**<br>
* Returns the class name for the list object.<br>
*<br>
* @return string class name<br>
*/<br>
function <span style="color: rgb(255, 0, 0);">getListClassName()</span>
{<br>
&nbsp;&nbsp;&nbsp; return "lamSmbDomainList";<br>
}<br>
<br>
<br>
/**<br>
&nbsp;* Generates the list view.<br>
&nbsp;*<br>
&nbsp;* @package lists<br>
&nbsp;* @author Roland Gruber<br>
&nbsp;* <br>
&nbsp;*/<br>
class <span style="color: rgb(255, 0, 0);">lamSmbDomainList</span>
extends <span style="font-weight: bold;">lamList</span> {<br>
<br>
&nbsp;&nbsp;&nbsp; /**<br>
&nbsp;&nbsp;&nbsp; &nbsp;* Constructor<br>
&nbsp;&nbsp;&nbsp; &nbsp;*<br>
&nbsp;&nbsp;&nbsp; &nbsp;* @param string $type account type<br>
&nbsp;&nbsp;&nbsp; &nbsp;* @return lamList list object<br>
&nbsp;&nbsp;&nbsp; &nbsp;*/<br>
&nbsp;&nbsp;&nbsp; function lamSmbDomainList($type) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; parent::lamList($type);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $this-&gt;labels = array(<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 'nav' =&gt;
_("%s domain(s) found"),<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
'error_noneFound' =&gt; _("No domains found!"),<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 'newEntry'
=&gt; _("New domain"),<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 'deleteEntry'
=&gt; _("Delete domain"),<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 'createPDF'
=&gt; _("Create PDF for selected domain(s)"),<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 'createPDFAll'
=&gt; _("Create PDF for all domains"));<br>
&nbsp;&nbsp;&nbsp; }<br>
<br>
}<br>
</td>
</tr>
</tbody>
</table>
<br>
<br>
<br>
<br>
<span style="font-weight: bold;"></span>
<h2><span style="font-weight: bold;"></span></h2>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,27 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Type HowTo - Default profile</title>
<link rel="stylesheet" type="text/css" href="style/layout.css">
</head>
<body>
<div style="text-align: center;">
<h1>Type HowTo - Default profile</h1>
<br>
<div style="text-align: left;"><br>
You have to provide a default profile for your account type. If you do
not want to specify default values then just provide an empty file.<br>
Save your profile as <span style="font-weight: bold;">default.&lt;your
type&gt;</span> in <span style="font-weight: bold;">config/profiles</span>.<br>
<br>
<br>
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br
style="font-weight: bold; text-decoration: underline;">
<br>
The <span style="font-style: italic;">smbDomain</span> type has only
an empty default profile. It is saved as <span
style="font-weight: bold;">config/profiles/default.smbDomain</span>.<br>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,144 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-15"
http-equiv="content-type">
<title>Type specification</title>
<style>
<!--
h2 {
color:darkblue;
}
h3 {
color:darkblue;
}
h4 {
color:darkblue;
}
table {
background-color:#bdcaff;
}
-->
</style>
</head>
<body>
<h1 style="text-align: center;">This document describes the type
interface for LDAP Account Manager</h1>
<br>
Account types are used to manage a group of accounts by grouping one or
more account modules. Examples for account types are user, group, host
and smbDomain.<br>
<br>
<h2>1. Location and naming of types<br>
</h2>
All LAM types are placed in lib/types/ and are named "&lt;class
name&gt;.inc".<br>
E.g. if you create a new type and its class name is "myUser" then the
filename would be "myUser.inc".<br>
<br>
The class name of a type must contain only a-z, A-Z, 0-9, -, and _.<br>
All type classes should extend the baseType class.<br>
<br>
<h2>2. Functions</h2>
<h3>2.1. getAlias<br>
</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top; text-align: center;"><span
style="font-weight: bold;">function getAlias()</span><br>
</td>
</tr>
</tbody>
</table>
<br>
Returns <span style="font-style: italic;"></span>the alias name for
this type. E.g. the alias for smbDomain is "Samba domains".<br>
<br>
<h3>2.2. getDescription<br>
</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top; text-align: center;"><span
style="font-weight: bold;">function getDescription()</span><br>
</td>
</tr>
</tbody>
</table>
<br>
Returns <span style="font-style: italic;"></span>a description for the
account type. This should be a short sentence describing the account
type.<br>
<br>
<h3>2.3. getListClassName<br>
</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top; text-align: center;"><span
style="font-weight: bold;">function getListClassName()</span><br>
</td>
</tr>
</tbody>
</table>
<br>
Here you can specify your own class to handle the list view. The class
must be a subclass of <span style="font-weight: bold;">lamList</span>.<br>
<br>
<h3>2.4. getDefaultListAttributes<br>
</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top; text-align: center;"><span
style="font-weight: bold;">function getDefaultListAttributes()</span><br>
</td>
</tr>
</tbody>
</table>
<br>
Returns <span style="font-style: italic;"></span>the default setting
for the displayed list attributes. It is used as default for config and
the syntax is equal to the config setting.<br>
<br>
<h3>2.5. getListAttributeDescriptions<br>
</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top; text-align: center;"><span
style="font-weight: bold;">function getListAttributeDescriptions()</span><br>
</td>
</tr>
</tbody>
</table>
<br>
Returns a hash array which contains predefined, translated descriptions
of LDAP attributes.<br>
<br>
<span style="text-decoration: underline; font-weight: bold;"><br>
Example:</span><br
style="text-decoration: underline; font-weight: bold;">
<br>
return array(<br>
&nbsp;&nbsp;&nbsp; "sambaSID" =&gt; _("Domain SID"),<br>
&nbsp;&nbsp;&nbsp; "sambaDomainName" =&gt; _("Domain name")<br>
&nbsp;&nbsp;&nbsp; );<br>
<br>
<br>
<br>
<br>
<br>
<span style="font-weight: bold;"></span><span style="font-weight: bold;"><span
style="font-style: italic;"></span></span><span
style="font-style: italic; font-weight: bold;"></span><span
style="font-style: italic; font-weight: bold;"></span><span
style="font-style: italic; font-weight: bold;"></span>
</body>
</html>

BIN
lam/graphics/group.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
lam/graphics/mailAlias.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 899 B

BIN
lam/graphics/smbDomain.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -153,21 +153,7 @@ $helpArray = array (
"601" => array ("ext" => "FALSE", "Headline" => _("OU-Editor") . " - " . _("New organizational unit"), "601" => array ("ext" => "FALSE", "Headline" => _("OU-Editor") . " - " . _("New organizational unit"),
"Text" => _("This will create a new organizational unit under the selected one.")), "Text" => _("This will create a new organizational unit under the selected one.")),
"602" => array ("ext" => "FALSE", "Headline" => _("OU-Editor") . " - " . _("Delete organizational unit"), "602" => array ("ext" => "FALSE", "Headline" => _("OU-Editor") . " - " . _("Delete organizational unit"),
"Text" => _("This will delete the selected organizational unit. The OU has to be empty.")), "Text" => _("This will delete the selected organizational unit. The OU has to be empty."))
"651" => array ("ext" => "FALSE", "Headline" => _("Domain name"),
"Text" => _("The name of your Windows domain or workgroup.")),
"652" => array ("ext" => "FALSE", "Headline" => _("Suffix"),
"Text" => _("The domain entry will be saved under this suffix.")),
"653" => array ("ext" => "FALSE", "Headline" => _("Domain SID"),
"Text" => _("The SID of your Samba server. Get it with \"net getlocalsid\".")),
"654" => array ("ext" => "FALSE", "Headline" => _("Next RID"),
"Text" => _("Next RID to use when creating accounts.")),
"655" => array ("ext" => "FALSE", "Headline" => _("Next User RID"),
"Text" => _("Next RID to use when creating user accounts.")),
"656" => array ("ext" => "FALSE", "Headline" => _("Next Group RID"),
"Text" => _("Next RID to use when creating groups.")),
"657" => array ("ext" => "FALSE", "Headline" => _("Algorithmic RID Base"),
"Text" => _("Used for calculating RIDs from UID/GID. Do not change if unsure."))
); );

View File

@ -360,10 +360,10 @@ function pwd_is_enabled($hash) {
/** /**
* Returns an array with all Samba 3 domain entries under the given suffix * Returns an array with all Samba 3 domain entries under the given suffix
* *
* @param string $suffix search suffix
* @return array list of samba3domain objects * @return array list of samba3domain objects
*/ */
function search_domains($suffix) { function search_domains() {
$suffix = $_SESSION['config']->get_Suffix('smbDomain');
$ret = array(); $ret = array();
$attr = array("DN", "sambaDomainName", "sambaSID", "sambaNextRid", "sambaNextGroupRid", $attr = array("DN", "sambaDomainName", "sambaSID", "sambaNextRid", "sambaNextGroupRid",
"sambaNextUserRid", "sambaAlgorithmicRidBase"); "sambaNextUserRid", "sambaAlgorithmicRidBase");
@ -498,7 +498,7 @@ function get_preg($argument, $regexp) {
$pregexpr = '/^(([a-zA-Z0-9\\.\\_-])+(,[a-zA-Z0-9\\.\\_-])*)*$/'; $pregexpr = '/^(([a-zA-Z0-9\\.\\_-])+(,[a-zA-Z0-9\\.\\_-])*)*$/';
break; break;
case "domainname": // Windows Domainname case "domainname": // Windows Domainname
$pregexpr = '/^([a-z0-9\\.\\_-])+$/'; $pregexpr = '/^([A-Za-z0-9\\.\\_-])+$/';
break; break;
case "unixhost": // Unix hosts case "unixhost": // Unix hosts
$pregexpr = '/^([a-z0-9,\\.\\_-])*$/'; $pregexpr = '/^([a-z0-9,\\.\\_-])*$/';
@ -533,6 +533,8 @@ function get_preg($argument, $regexp) {
case 'dn': // LDAP DN case 'dn': // LDAP DN
$pregexpr = '/^([^=,]+=[^=,]+)(,([^=,]+=[^=,]+))*$/'; $pregexpr = '/^([^=,]+=[^=,]+)(,([^=,]+=[^=,]+))*$/';
break; break;
case 'domainSID': // Samba domain SID
$pregexpr = "/^S\\-[0-9]\\-[0-9]\\-[0-9]{2,2}\\-[0-9]+\\-[0-9]+\\-[0-9]+$/";
} }
if ($pregexpr!='') if ($pregexpr!='')
if (preg_match($pregexpr, $argument)) { if (preg_match($pregexpr, $argument)) {

90
lam/lib/baseType.inc Normal file
View File

@ -0,0 +1,90 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 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
*/
/**
* This is the parent class of all account types.
*
* @package types
* @author Roland Gruber
*/
/**
* This is the parent class of all account types.
*
* @package types
*/
class baseType {
/**
* Returns the alias name of this account type.
* This function must be overwritten by the child classes.
*
* @return string alias name
*/
function getAlias() {
return "baseType";
}
/**
* Returns the description of this account type.
* This function must be overwritten by the child classes.
*
* @return string description
*/
function getDescription() {
return "base type";
}
/**
* Returns the class name for the list object.
*
* @return string class name
*/
function getListClassName() {
return "lamList";
}
/**
* Returns the default attribute list for this account type.
* This function must be overwritten by the child classes.
*
* @return string attribute list
*/
function getDefaultListAttributes() {
return "dn:DN,objectClass:Object classes";
}
/**
* Returns a list of attributes which have a translated description.
* This is used for the head row in the list view.
*
* @return array list of descriptions
*/
function getListAttributeDescriptions() {
return array();
}
}
?>

View File

@ -33,6 +33,8 @@ $Id$
include_once("status.inc"); include_once("status.inc");
/** Used to get module information. */ /** Used to get module information. */
include_once("modules.inc"); include_once("modules.inc");
/** Used to get type information. */
include_once("types.inc");
/** /**
* Sets language settings for automatic translation * Sets language settings for automatic translation
@ -129,28 +131,9 @@ class Config {
/** Password to edit preferences */ /** Password to edit preferences */
var $Passwd; var $Passwd;
/** LDAP suffix for users */
var $usersuffix;
/** LDAP suffix for groups */
var $groupsuffix;
/** LDAP suffix for Samba hosts */
var $hostsuffix;
/** LDAP suffix for Samba 3 domains */
var $domainsuffix;
/** LDAP suffix for tree view */ /** LDAP suffix for tree view */
var $treesuffix; var $treesuffix;
/** Attributes that are shown in the user list */
var $userlistAttributes;
/** Attributes that are shown in the group list */
var $grouplistAttributes;
/** Attributes that are shown in the host list */
var $hostlistAttributes;
/** Maximum number of rows shown in user/group/host lists */ /** Maximum number of rows shown in user/group/host lists */
var $maxlistentries; var $maxlistentries;
@ -160,6 +143,9 @@ class Config {
/** module settings */ /** module settings */
var $moduleSettings = array(); var $moduleSettings = array();
/** type settings */
var $typeSettings = array();
/** /**
* Path to external lamdaemon script on server where it is executed * Path to external lamdaemon script on server where it is executed
* *
@ -179,20 +165,16 @@ class Config {
/** LDAP cache timeout */ /** LDAP cache timeout */
var $cachetimeout; var $cachetimeout;
var $usermodules = "posixAccount,shadowAccount,quota"; /** Active account types */
/** Account modules for groups */ var $activeTypes = "user,group,host,smbDomain";
var $groupmodules = "posixGroup,quota";
/** Account modules for hosts */
var $hostmodules = "account,sambaSamAccount";
/** Name of configuration file */ /** Name of configuration file */
var $file; var $file;
/** List of all settings in config file */ /** List of all settings in config file */
var $settings = array("ServerURL", "Passwd", "Admins", "usersuffix", "groupsuffix", "hostsuffix", "treesuffix", var $settings = array("ServerURL", "Passwd", "Admins", "treesuffix", "maxlistentries",
"domainsuffix", "userlistAttributes", "grouplistAttributes", "hostlistAttributes", "maxlistentries",
"defaultLanguage", "scriptPath", "scriptServer", "cachetimeout", "defaultLanguage", "scriptPath", "scriptServer", "cachetimeout",
"usermodules", "groupmodules", "hostmodules", "modules"); "modules", "activeTypes", "types");
/** /**
@ -233,7 +215,13 @@ class Config {
if (strtolower(substr($line, 0, $keylen + 2)) == "modules: ") { if (strtolower(substr($line, 0, $keylen + 2)) == "modules: ") {
$option = substr($line, $keylen + 2, strlen($line) - $keylen - 2); $option = substr($line, $keylen + 2, strlen($line) - $keylen - 2);
$pos = strpos($option, ":"); $pos = strpos($option, ":");
$this->moduleSettings[substr($option, 0, $pos)] = explode("+::+", substr($option, $pos + 2, strlen($option) - $pos - 2)); $this->moduleSettings[substr($option, 0, $pos)] = explode("+::+", substr($option, $pos + 2));
}
// type settings
elseif (strtolower(substr($line, 0, $keylen + 2)) == "types: ") {
$option = substr($line, $keylen + 2, strlen($line) - $keylen - 2);
$pos = strpos($option, ":");
$this->typeSettings[substr($option, 0, $pos)] = substr($option, $pos + 2);
} }
// general settings // general settings
else { else {
@ -246,7 +234,7 @@ class Config {
fclose($file); fclose($file);
} }
// check modules // check modules
$scopes = array('user', 'group', 'host'); $scopes = $this->get_ActiveTypes();
for ($s = 0; $s < sizeof($scopes); $s++) { for ($s = 0; $s < sizeof($scopes); $s++) {
$scope = $scopes[$s]; $scope = $scopes[$s];
$moduleVar = $scope . "modules"; $moduleVar = $scope . "modules";
@ -293,6 +281,15 @@ class Config {
$file_array[$i] = "modules: " . $name . ": " . implode("+::+", $this->moduleSettings[$name]) . "\n"; $file_array[$i] = "modules: " . $name . ": " . implode("+::+", $this->moduleSettings[$name]) . "\n";
$mod_saved[] = $name; // mark keyword as saved $mod_saved[] = $name; // mark keyword as saved
} }
// type settings
elseif (strtolower(substr($line, 0, $keylen + 2)) == "types: ") {
$option = substr($line, $keylen + 2, strlen($line) - $keylen - 2);
$pos = strpos($option, ":");
$name = substr($option, 0, $pos);
if (!isset($this->typeSettings[$name])) continue;
$file_array[$i] = "types: " . $name . ": " . $this->typeSettings[$name] . "\n";
$mod_saved[] = $name; // mark keyword as saved
}
// general settings // general settings
else { else {
$file_array[$i] = $keyword . ": " . $this->$keyword . "\n"; $file_array[$i] = $keyword . ": " . $this->$keyword . "\n";
@ -308,30 +305,14 @@ class Config {
if (!in_array("Admins", $saved)) array_push($file_array, "\n\n# list of users who are allowed to use LDAP Account Manager\n" . if (!in_array("Admins", $saved)) array_push($file_array, "\n\n# list of users who are allowed to use LDAP Account Manager\n" .
"# names have to be seperated by semicolons\n" . "# names have to be seperated by semicolons\n" .
"# e.g. admins: cn=admin,dc=yourdomain,dc=org;cn=root,dc=yourdomain,dc=org\n" . "admins: " . $this->Admins . "\n"); "# e.g. admins: cn=admin,dc=yourdomain,dc=org;cn=root,dc=yourdomain,dc=org\n" . "admins: " . $this->Admins . "\n");
if (!in_array("usersuffix", $saved)) array_push($file_array, "\n\n# suffix of users\n" .
"# e.g. ou=People,dc=yourdomain,dc=org\n" . "usersuffix: " . $this->usersuffix . "\n");
if (!in_array("groupsuffix", $saved)) array_push($file_array, "\n\n# suffix of groups\n" .
"# e.g. ou=Groups,dc=yourdomain,dc=org\n" . "groupsuffix: " . $this->groupsuffix . "\n");
if (!in_array("hostsuffix", $saved)) array_push($file_array, "\n\n# suffix of hosts\n" .
"# e.g. ou=machines,dc=yourdomain,dc=org\n" . "hostsuffix: " . $this->hostsuffix . "\n");
if (!in_array("domainsuffix", $saved)) array_push($file_array, "\n\n# suffix of Samba 3 domains\n" .
"# e.g. ou=domains,dc=yourdomain,dc=org\n" . "domainsuffix: " . $this->domainsuffix . "\n");
if (!in_array("treesuffix", $saved)) array_push($file_array, "\n\n# suffix of tree view\n" . if (!in_array("treesuffix", $saved)) array_push($file_array, "\n\n# suffix of tree view\n" .
"# e.g. dc=yourdomain,dc=org\n" . "treesuffix: " . $this->treesuffix . "\n"); "# e.g. dc=yourdomain,dc=org\n" . "treesuffix: " . $this->treesuffix . "\n");
if (!in_array("userlistAttributes", $saved)) array_push($file_array, "\n\n# list of attributes to show in user list\n# entries can either be predefined values (e.g. '#cn' or '#uid')" .
"\n# or individual ones (e.g. 'uid:User ID' or 'host:Host Name')\n# values have to be seperated by semicolons\n" . "userlistAttributes: " . $this->userlistAttributes . "\n");
if (!in_array("grouplistAttributes", $saved)) array_push($file_array, "\n\n# list of attributes to show in group list\n# entries can either be predefined values (e.g. '#cn' or '#gidNumber')" .
"\n# or individual ones (e.g. 'cn:Group Name')\n# values have to be seperated by semicolons\n" . "grouplistAttributes: " . $this->grouplistAttributes . "\n");
if (!in_array("hostlistAttributes", $saved)) array_push($file_array, "\n\n# list of attributes to show in host list\n# entries can either be predefined values (e.g. '#cn' or '#uid')" .
"\n# or individual ones (e.g. 'cn:Host Name')\n# values have to be seperated by semicolons\n" . "hostlistAttributes: " . $this->hostlistAttributes . "\n");
if (!in_array("maxlistentries", $saved)) array_push($file_array, "\n\n# maximum number of rows to show in user/group/host lists\n" . "maxlistentries: " . $this->maxlistentries . "\n"); if (!in_array("maxlistentries", $saved)) array_push($file_array, "\n\n# maximum number of rows to show in user/group/host lists\n" . "maxlistentries: " . $this->maxlistentries . "\n");
if (!in_array("defaultLanguage", $saved)) array_push($file_array, "\n\n# default language (a line from config/language)\n" . "defaultLanguage: " . $this->defaultLanguage . "\n"); if (!in_array("defaultLanguage", $saved)) array_push($file_array, "\n\n# default language (a line from config/language)\n" . "defaultLanguage: " . $this->defaultLanguage . "\n");
if (!in_array("scriptPath", $saved)) array_push($file_array, "\n\n# Path to external Script\n" . "scriptPath: " . $this->scriptPath . "\n"); if (!in_array("scriptPath", $saved)) array_push($file_array, "\n\n# Path to external Script\n" . "scriptPath: " . $this->scriptPath . "\n");
if (!in_array("scriptServer", $saved)) array_push($file_array, "\n\n# Server of external Script\n" . "scriptServer: " . $this->scriptServer . "\n"); if (!in_array("scriptServer", $saved)) array_push($file_array, "\n\n# Server of external Script\n" . "scriptServer: " . $this->scriptServer . "\n");
if (!in_array("cachetimeout", $saved)) array_push($file_array, "\n\n# Number of minutes LAM caches LDAP searches.\n" . "cacheTimeout: " . $this->cachetimeout . "\n"); if (!in_array("cachetimeout", $saved)) array_push($file_array, "\n\n# Number of minutes LAM caches LDAP searches.\n" . "cacheTimeout: " . $this->cachetimeout . "\n");
if (!in_array("usermodules", $saved)) array_push($file_array, "\n\n# List of used user modules\n" . "usermodules: " . $this->usermodules . "\n"); if (!in_array("activeTypes", $saved)) array_push($file_array, "\n\n# List of active account types.\n" . "activeTypes: " . $this->activeTypes . "\n");
if (!in_array("groupmodules", $saved)) array_push($file_array, "\n\n# List of used group modules\n" . "groupmodules: " . $this->groupmodules . "\n");
if (!in_array("hostmodules", $saved)) array_push($file_array, "\n\n# List of used host modules\n" . "hostmodules: " . $this->hostmodules . "\n");
// check if all module settings were added // check if all module settings were added
$m_settings = array_keys($this->moduleSettings); $m_settings = array_keys($this->moduleSettings);
for ($i = 0; $i < sizeof($m_settings); $i++) { for ($i = 0; $i < sizeof($m_settings); $i++) {
@ -339,54 +320,27 @@ class Config {
array_push($file_array, "modules: " . $m_settings[$i] . ": " . implode("+::+", $this->moduleSettings[$m_settings[$i]]) . "\n"); array_push($file_array, "modules: " . $m_settings[$i] . ": " . implode("+::+", $this->moduleSettings[$m_settings[$i]]) . "\n");
} }
} }
// check if all type settings were added
$t_settings = array_keys($this->typeSettings);
for ($i = 0; $i < sizeof($t_settings); $i++) {
if (!in_array($t_settings[$i], $mod_saved)) {
array_push($file_array, "types: " . $t_settings[$i] . ": " . $this->typeSettings[$t_settings[$i]] . "\n");
}
}
$file = fopen($conffile, "w"); $file = fopen($conffile, "w");
if ($file) { if ($file) {
for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]); for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]);
fclose($file); fclose($file);
@chmod ($conffile, 0600); @chmod ($conffile, 0600);
StatusMessage("INFO", _("Your settings were successfully saved.") , " (" . $conffile . ")");
} }
else { else {
StatusMessage("ERROR", "", _("Cannot open config file!") . " (" . $conffile . ")"); StatusMessage("ERROR", _("Cannot open config file!") . " (" . $conffile . ")");
exit; exit;
} }
} }
} }
/** Prints current preferences */
function printconf() {
echo "<b>" . _("Server address") . ": </b>" . $this->ServerURL . "<br>\n";
echo "<b>" . _("Cache timeout") . ": </b>" . $this->cachetimeout . "<br>\n";
echo "<b>" . _("UserSuffix") . ": </b>" . $this->usersuffix . "<br>\n";
echo "<b>" . _("GroupSuffix") . ": </b>" . $this->groupsuffix . "<br>\n";
echo "<b>" . _("HostSuffix") . ": </b>" . $this->hostsuffix . "<br>\n";
echo "<b>" . _("DomainSuffix") . ": </b>" . $this->domainsuffix . "<br>\n";
echo "<b>" . _("TreeSuffix") . ": </b>" . $this->treesuffix . "<br>\n";
echo "<b>" . _("Attributes in User List") . ": </b>" . $this->userlistAttributes . "<br>\n";
echo "<b>" . _("Attributes in Group List") . ": </b>" . $this->grouplistAttributes . "<br>\n";
echo "<b>" . _("Attributes in Host List") . ": </b>" . $this->hostlistAttributes . "<br>\n";
echo "<b>" . _("Maximum list entries") . ": </b>" . $this->maxlistentries . "<br>\n";
echo "<b>" . _("Default language") . ": </b>" . $this->defaultLanguage . "<br>\n";
echo "<b>" . _("Path to external script") . ": </b>" . $this->scriptPath . "<br>\n";
echo "<b>" . _("Server of external script") . ": </b>" . $this->scriptServer . "<br>\n";
echo "<b>" . _("List of valid users") . ": </b>" . $this->Admins . "<br>\n";
echo "<b>" . _("User modules") . ": </b>" . $this->usermodules . "<br>\n";
echo "<b>" . _("Group modules") . ": </b>" . $this->groupmodules . "<br>\n";
echo "<b>" . _("Host modules") . ": </b>" . $this->hostmodules . "<br><br>\n";
echo "<b>" . _("Module settings") . ": </b><br>\n";
echo "<ul>\n";
$names = array_keys($this->moduleSettings);
$descriptions = getConfigDescriptions();
$descriptions = $descriptions['descriptions'];
for ($i = 0; $i < sizeof($names); $i++) {
echo "<li><b>";
// print description if available
if (isset($descriptions[$names[$i]])) echo $descriptions[$names[$i]];
else echo $names[$i];
echo ": </b>" . implode(", ", $this->moduleSettings[$names[$i]]) . "</li>\n";
}
echo "</ul>\n";
}
// functions to read/write preferences // functions to read/write preferences
/** /**
@ -471,24 +425,12 @@ class Config {
* @return string the LDAP suffix * @return string the LDAP suffix
*/ */
function get_Suffix($scope) { function get_Suffix($scope) {
switch ($scope) { if ($scope == "tree") {
case 'user':
return $this->usersuffix;
break;
case 'group':
return $this->groupsuffix;
break;
case 'host':
return $this->hostsuffix;
break;
case 'domain':
return $this->domainsuffix;
break;
case 'tree':
return $this->treesuffix; return $this->treesuffix;
break;
} }
return ""; else {
return $this->typeSettings['suffix_' . $scope];
}
} }
/** /**
@ -503,22 +445,11 @@ class Config {
elseif (!is_string($value)) { elseif (!is_string($value)) {
return false; return false;
} }
switch ($scope) { if ($scope == "tree") {
case 'user':
$this->usersuffix = $value;
break;
case 'group':
$this->groupsuffix = $value;
break;
case 'host':
$this->hostsuffix = $value;
break;
case 'domain':
$this->domainsuffix = $value;
break;
case 'tree':
$this->treesuffix = $value; $this->treesuffix = $value;
break; }
else {
$this->typeSettings['suffix_' . $scope] = $value;
} }
return true; return true;
} }
@ -530,20 +461,7 @@ class Config {
* @return string the attribute list * @return string the attribute list
*/ */
function get_listAttributes($scope) { function get_listAttributes($scope) {
switch ($scope) { return $this->typeSettings['attr_' . $scope];
case 'user':
return $this->userlistAttributes;
break;
case 'group':
return $this->grouplistAttributes;
break;
case 'host':
return $this->hostlistAttributes;
break;
default:
return '';
break;
}
} }
/** /**
@ -555,20 +473,7 @@ class Config {
*/ */
function set_listAttributes($value, $scope) { function set_listAttributes($value, $scope) {
if (is_string($value) && eregi("^((#[^:;]+)|([^:;]*:[^:;]+))(;((#[^:;]+)|([^:;]*:[^:;]+)))*$", $value)) { if (is_string($value) && eregi("^((#[^:;]+)|([^:;]*:[^:;]+))(;((#[^:;]+)|([^:;]*:[^:;]+)))*$", $value)) {
switch ($scope) { $this->typeSettings['attr_' . $scope] = $value;
case 'user':
$this->userlistAttributes = $value;
break;
case 'group':
$this->grouplistAttributes = $value;
break;
case 'host':
$this->hostlistAttributes = $value;
break;
default:
return false;
break;
}
return true; return true;
} }
else { else {
@ -576,20 +481,6 @@ class Config {
} }
} }
/**
* Sets the list of attributes to show in group list
*
* @param string $value new attribute string
* @return boolean true if $value has correct format
*/
function set_grouplistAttributes($value) {
if (is_string($value) && eregi("^((#[^:;]+)|([^:;]*:[^:;]+))(;((#[^:;]+)|([^:;]*:[^:;]+)))*$", $value)) {
$this->grouplistAttributes = $value;
}
else return false;
return true;
}
/** /**
* Returns the maximum number of rows in user/group/host lists * Returns the maximum number of rows in user/group/host lists
* *
@ -718,21 +609,12 @@ class Config {
* @return array user modules * @return array user modules
*/ */
function get_AccountModules($scope) { function get_AccountModules($scope) {
switch ($scope) { if (isset($this->typeSettings["modules_" . $scope])) {
case 'user': return explode(",", $this->typeSettings["modules_" . $scope]);
return explode(",", $this->usermodules); }
break; else {
case 'group': return array();
return explode(",", $this->groupmodules);
break;
case 'host':
return explode(",", $this->hostmodules);
break;
default:
return array();
break;
} }
} }
/** /**
@ -752,19 +634,7 @@ class Config {
// check depends/conflicts // check depends/conflicts
if (check_module_conflicts($modules, getModulesDependencies($scope)) != false) return false; if (check_module_conflicts($modules, getModulesDependencies($scope)) != false) return false;
if (check_module_depends($modules, getModulesDependencies($scope)) != false) return false; if (check_module_depends($modules, getModulesDependencies($scope)) != false) return false;
switch ($scope) { $this->typeSettings["modules_" . $scope] = implode(",", $modules);
case 'user':
$this->usermodules = implode(",", $modules);
break;
case 'group':
$this->groupmodules = implode(",", $modules);
break;
case 'host':
$this->hostmodules = implode(",", $modules);
break;
default:
break;
}
return true; return true;
} }
@ -789,6 +659,45 @@ class Config {
return $this->moduleSettings; return $this->moduleSettings;
} }
/**
* Returns a list of active account types.
*
* @return array list of types
*/
function get_ActiveTypes() {
return explode(",", $this->activeTypes);
}
/**
* Sets the list of active types.
*
* @param array list of types
*/
function set_ActiveTypes($types) {
$this->activeTypes = implode(",", $types);
}
/**
* Sets the settings for the account types.
*
* @param array $settings list of type setting array(name => value)
* @return boolean true if $settings has correct format
*/
function set_typeSettings($settings) {
if (!is_array($settings)) return false;
$this->typeSettings = $settings;
return true;
}
/**
* Returns a list of saved type settings
*
* @return array list of settings: array(name => value)
*/
function get_typeSettings() {
return $this->typeSettings;
}
} }

View File

@ -29,26 +29,157 @@ $Id$
* @author Roland Gruber * @author Roland Gruber
*/ */
/** Used to get type information. */
include_once("types.inc");
/** Used to get PDF information. */
include_once("pdfstruct.inc");
/**
* Generates the list view.
*
* @package lists
* @author Roland Gruber
*
*/
class lamList {
/** Account type */
var $type;
/** current page number */
var $page = 1;
/** list of LDAP attributes */
var $attrArray = array();
/** list of attribute descriptions */
var $descArray = array();
/** maximum count of entries per page */
var $maxPageEntries = 10;
/** sort column name */
var $sortColumn;
/** LDAP suffix */
var $suffix;
/** refresh page switch */
var $refresh = true;
/** LDAP entries */
var $entries;
/** filter string to include in URL */
var $filterText;
/** list of possible LDAP suffixes(organizational units) */
var $possibleSuffixes;
/** list of account specific labels */
var $labels;
/**
* Constructor
*
* @param string $type account type
* @return lamList list object
*/
function lamList($type) {
$this->type = $type;
$this->labels = array(
'nav' => _("%s object(s) found"),
'error_noneFound' => _("No objects found!"),
'newEntry' => _("New object"),
'deleteEntry' => _("Delete object"),
'createPDF' => _("Create PDF for selected object(s)"),
'createPDFAll' => _("Create PDF for all objects"));
}
/**
* Prints the HTML code to display the list view.
*/
function showPage() {
// do POST actions
$this->listDoPost();
// get some parameters
$this->listGetParams();
// print HTML head
$this->listPrintHeader();
// refresh data if needed
if ($this->refresh) $this->listRefreshData();
// filter entries
$filteredEntries = $this->listFilterAccounts();
// sort rows by sort column
if ($filteredEntries) {
$filteredEntries = $this->listSort($filteredEntries);
}
// show form
echo ("<form action=\"list.php?type=" . $this->type . "&amp;norefresh=true\" method=\"post\">\n");
// draw account list if accounts were found
if (sizeof($filteredEntries) > 0) {
// navigation bar
$this->listDrawNavigationBar(sizeof($filteredEntries));
echo ("<br>\n");
// account table head
$this->listPrintTableHeader();
// account table body
$this->listPrintTableBody($filteredEntries);
// navigation bar
$this->listDrawNavigationBar(sizeof($filteredEntries));
echo ("<br>\n");
// print combobox with possible sub-DNs
$this->listShowOUSelection();
// buttons
$this->listPrintButtons(false);
}
else {
// account table head
$this->listPrintTableHeader();
echo "</table><br>\n";
// print combobox with possible sub-DNs
$this->listShowOUSelection();
echo ("<br>\n");
$this->listPrintButtons(true);
}
echo ("</form>\n");
echo "</body></html>\n";
}
/** /**
* Builds the regular expressions from the filter values. * Builds the regular expressions from the filter values.
* *
* @param array $attributes list of displayed attributes
* @return array filter data array($attribute => array('regex' => $reg, 'original' => $orig)) * @return array filter data array($attribute => array('regex' => $reg, 'original' => $orig))
* $reg is the regular expression to use, $orig the user's unmodified input string * $reg is the regular expression to use, $orig the user's unmodified input string
*/ */
function listBuildFilter($attributes) { function listBuildFilter() {
$filter = array(); $filter = array();
for ($i = 0; $i < sizeof($attributes); $i++) { // build filter array
if (isset($_POST["filter" . strtolower($attributes[$i])]) && eregi('^([0-9a-z _\\*\\$-])+$', $_POST["filter" . strtolower($attributes[$i])])) { for ($i = 0; $i < sizeof($this->attrArray); $i++) {
$filter[$attributes[$i]]['original'] = $_POST["filter" . strtolower($attributes[$i])]; if (isset($_POST["filter" . strtolower($this->attrArray[$i])]) && eregi('^([0-9a-z _\\*\\$-])+$', $_POST["filter" . strtolower($this->attrArray[$i])])) {
$filter[$attributes[$i]]['regex'] = $_POST["filter" . strtolower($attributes[$i])]; $filter[$this->attrArray[$i]]['original'] = $_POST["filter" . strtolower($this->attrArray[$i])];
$filter[$this->attrArray[$i]]['regex'] = $_POST["filter" . strtolower($this->attrArray[$i])];
// replace special characters // replace special characters
$filter[$attributes[$i]]['regex'] = str_replace("*", "(.)*", $filter[$attributes[$i]]['regex']); $filter[$this->attrArray[$i]]['regex'] = str_replace("*", "(.)*", $filter[$this->attrArray[$i]]['regex']);
$filter[$attributes[$i]]['regex'] = str_replace('$', '[$]', $filter[$attributes[$i]]['regex']); $filter[$this->attrArray[$i]]['regex'] = str_replace('$', '[$]', $filter[$this->attrArray[$i]]['regex']);
// add string begin and end // add string begin and end
$filter[$attributes[$i]]['regex'] = "^" . $filter[$attributes[$i]]['regex'] . "$"; $filter[$this->attrArray[$i]]['regex'] = "^" . $filter[$this->attrArray[$i]]['regex'] . "$";
} }
} }
// save filter string
$filterAttributes = array_keys($filter);
$searchFilter = array();
for ($i = 0; $i < sizeof($filterAttributes); $i++) {
$searchFilter[] = "filter" . $filterAttributes[$i] . "=" . $filter[$filterAttributes[$i]]['original'];
}
if (sizeof($searchFilter) > 0) {
$searchFilter = "&amp;" . implode("&amp;", $searchFilter);
}
else {
$searchFilter = "";
}
$this->filterText = $searchFilter;
return $filter; return $filter;
} }
@ -56,11 +187,11 @@ function listBuildFilter($attributes) {
/** /**
* Removes all entries which do not fit to the filter. * Removes all entries which do not fit to the filter.
* *
* @param array $entries list of accounts
* @param array $filter attribute filter
* @return array filtered list of accounts * @return array filtered list of accounts
*/ */
function listFilterAccounts($entries, $filter) { function listFilterAccounts() {
$entries = $this->entries;
$filter = $this->listBuildFilter();
$attributes = array_keys($filter); $attributes = array_keys($filter);
for ($r = 0; $r < sizeof($entries); $r++) { for ($r = 0; $r < sizeof($entries); $r++) {
for ($a = 0; $a < sizeof($attributes); $a++) { for ($a = 0; $a < sizeof($attributes); $a++) {
@ -81,6 +212,7 @@ function listFilterAccounts($entries, $filter) {
} }
} }
} }
if (sizeof($entries) == 0) StatusMessage("WARN", "", $this->labels['error_noneFound']); // TODO correct message
return $entries; return $entries;
} }
@ -88,12 +220,17 @@ function listFilterAccounts($entries, $filter) {
/** /**
* Sorts an account list by a given attribute * Sorts an account list by a given attribute
* *
* @param string $sort the attribute by which to sort
* @param array $attr_array array of displayed attributes
* @param array $info the account list * @param array $info the account list
* @return array sorted account list * @return array sorted account list
*/ */
function listSort($sort, $attr_array, $info) { function listSort($info) {
if (!is_array($this->attrArray)) return $info;
if (!is_string($this->sortColumn)) return $info;
// sort and return account list
usort($info, array($this, "cmp_array"));
return $info;
}
/** /**
* Compare function used for usort-method * Compare function used for usort-method
@ -107,74 +244,56 @@ function listSort($sort, $attr_array, $info) {
*/ */
function cmp_array($a, $b) { function cmp_array($a, $b) {
// sort specifies the sort column // sort specifies the sort column
global $sort; $sort = $this->sortColumn;
global $attr_array; $attr_array = $this->attrArray;
// sort by first column if no attribute is given // sort by first column if no attribute is given
if (!$sort) $sort = strtolower($attr_array[0]); if (!$sort) $sort = strtolower($attr_array[0]);
if ($sort != "dn") { if ($sort != "dn") {
// sort by first attribute with name $sort // sort by first attribute with name $sort
if ($a[$sort][0] == $b[$sort][0]) return 0; return strcmp($a[$sort][0], $b[$sort][0]);
elseif ($a[$sort][0] == max($a[$sort][0], $b[$sort][0])) return 1;
else return -1;
} }
else { else {
if ($a[$sort] == $b[$sort]) return 0; return strcmp($a[$sort], $b[$sort]);
elseif ($a[$sort] == max($a[$sort], $b[$sort])) return 1;
else return -1;
} }
} }
if (!is_array($attr_array)) return $info;
if (!is_string($sort)) return $info;
// sort and return account list
usort($info, "cmp_array");
return $info;
}
/** /**
* Draws a navigation bar to switch between pages * Draws a navigation bar to switch between pages
* *
* @param integer $count number of account entries * @param integer $count number of account entries
* @param integer $max_page_entries maximum number of account per page
* @param integer $page current page number
* @param string $sort sort attribute
* @param string $searchFilter LDAP search filter
* @param string $scope account type (user/group/host/domain)
* @param string $text string including the number of accounts
*/ */
function listDrawNavigationBar($count, $max_page_entries, $page, $sort, $searchFilter, $scope, $text) { function listDrawNavigationBar($count) {
echo("<table class=\"" . $scope . "nav\" width=\"100%\" border=\"0\">\n"); echo("<table class=\"" . $this->type . "nav\" width=\"100%\" border=\"0\">\n");
echo("<tr>\n"); echo("<tr>\n");
echo("<td><input type=\"submit\" name=\"refresh\" value=\"" . _("Refresh") . "\">&nbsp;&nbsp;"); echo("<td><input type=\"submit\" name=\"refresh\" value=\"" . _("Refresh") . "\">&nbsp;&nbsp;");
if ($page != 1) { if ($this->page != 1) {
echo("<a href=\"list" . $scope . "s.php?norefresh=true&amp;page=" . ($page - 1) . "&amp;sort=" . $sort . $searchFilter . "\">&lt;=</a>\n"); echo("<a href=\"list.php?type=" . $this->type . "&amp;norefresh=true&amp;page=" . ($this->page - 1) . "&amp;sort=" . $this->sortColumn . $this->filterText . "\">&lt;=</a>\n");
} }
else { else {
echo("&lt;="); echo("&lt;=");
} }
echo("&nbsp;"); echo("&nbsp;");
if ($page < ($count / $max_page_entries)) { if ($this->page < ($count / $this->maxPageEntries)) {
echo("<a href=\"list" . $scope . "s.php?norefresh=true&amp;page=" . ($page + 1) . "&amp;sort=" . $sort . $searchFilter . "\">=&gt;</a>\n"); echo("<a href=\"list.php?type=" . $this->type . "&amp;norefresh=true&amp;page=" . ($this->page + 1) . "&amp;sort=" . $this->sortColumn . $this->filterText . "\">=&gt;</a>\n");
} }
else { else {
echo("=&gt;</td>"); echo("=&gt;</td>");
} }
echo("<td class=\"" . $scope . "nav-text\">"); echo("<td class=\"" . $this->type . "nav-text\">");
echo"&nbsp;"; echo"&nbsp;";
printf($text, $count); printf($this->labels['nav'], $count);
echo("</td>"); echo("</td>");
echo("<td class=\"" . $scope . "nav-activepage\" align=\"right\">"); echo("<td class=\"" . $this->type . "nav-activepage\" align=\"right\">");
for ($i = 0; $i < ($count / $max_page_entries); $i++) { for ($i = 0; $i < ($count / $this->maxPageEntries); $i++) {
if ($i == $page - 1) { if ($i == $this->page - 1) {
echo("&nbsp;" . ($i + 1)); echo("&nbsp;" . ($i + 1));
} }
else { else {
echo("&nbsp;<a href=\"list" . $scope . "s.php?norefresh=true&amp;page=" . ($i + 1) . "&amp;sort=" . $sort . "\">" . ($i + 1) . "</a>\n"); echo("&nbsp;<a href=\"list.php?type=" . $this->type . "&amp;norefresh=true&amp;page=" . ($i + 1) . "&amp;sort=" . $this->sortColumn . "\">" . ($i + 1) . "</a>\n");
} }
} }
echo("</td></tr></table>\n"); echo("</td></tr></table>\n");
@ -182,31 +301,24 @@ function listDrawNavigationBar($count, $max_page_entries, $page, $sort, $searchF
/** /**
* Prints the attribute and filter row at the account table head * Prints the attribute and filter row at the account table head
*
* @param string $scope account type (user, group, host)
* @param string $searchFilter search filter for hyperlinks
* @param array $desc_array list of attribute descriptions
* @param array $attr_array list of attribute names
* @param array $_POST HTTP-POST values
* @param string $sort sort attribute
*/ */
function listPrintTableHeader($scope, $searchFilter, $desc_array, $attr_array, $_POST, $sort) { function listPrintTableHeader() {
// print table header // print table header
echo "<table rules=\"all\" class=\"" . $scope . "list\" width=\"100%\">\n"; echo "<table rules=\"all\" class=\"" . $this->type . "list\" width=\"100%\">\n";
echo "<tr class=\"" . $scope . "list-head\">\n<th width=22 height=34></th>\n<th></th>\n"; echo "<tr class=\"" . $this->type . "list-head\">\n<th width=22 height=34></th>\n<th></th>\n";
// table header // table header
for ($k = 0; $k < sizeof($desc_array); $k++) { for ($k = 0; $k < sizeof($this->descArray); $k++) {
if (strtolower($attr_array[$k]) == $sort) { if (strtolower($this->attrArray[$k]) == $this->sortColumn) {
echo "<th class=\"" . $scope . "list-sort\"><a href=\"list" . $scope . "s.php?". echo "<th class=\"" . $this->type . "list-sort\"><a href=\"list.php?type=" . $this->type . "&amp;".
"sort=" . strtolower($attr_array[$k]) . $searchFilter . "&amp;norefresh=y" . "\">" . $desc_array[$k] . "</a></th>\n"; "sort=" . strtolower($this->attrArray[$k]) . $this->filterText . "&amp;norefresh=y" . "\">" . $this->descArray[$k] . "</a></th>\n";
} }
else echo "<th><a href=\"list" . $scope . "s.php?". else echo "<th><a href=\"list.php?type=" . $this->type . "&amp;".
"sort=" . strtolower($attr_array[$k]) . $searchFilter . "&amp;norefresh=y" . "\">" . $desc_array[$k] . "</a></th>\n"; "sort=" . strtolower($this->attrArray[$k]) . $this->filterText . "&amp;norefresh=y" . "\">" . $this->descArray[$k] . "</a></th>\n";
} }
echo "</tr>\n"; echo "</tr>\n";
// print filter row // print filter row
echo "<tr align=\"center\" class=\"" . $scope . "list\">\n"; echo "<tr align=\"center\" class=\"" . $this->type . "list\">\n";
echo "<td width=22 height=34>"; echo "<td width=22 height=34>";
// help link // help link
echo "<a href=\"../help.php?HelpNumber=250\" target=\"lamhelp\">"; echo "<a href=\"../help.php?HelpNumber=250\" target=\"lamhelp\">";
@ -217,29 +329,83 @@ function listPrintTableHeader($scope, $searchFilter, $desc_array, $attr_array, $
echo "<input type=\"submit\" name=\"apply_filter\" value=\"" . _("Filter") . "\">"; echo "<input type=\"submit\" name=\"apply_filter\" value=\"" . _("Filter") . "\">";
echo "</td>\n"; echo "</td>\n";
// print input boxes for filters // print input boxes for filters
for ($k = 0; $k < sizeof ($desc_array); $k++) { for ($k = 0; $k < sizeof ($this->descArray); $k++) {
$value = ""; $value = "";
if (isset($_POST["filter" . strtolower($attr_array[$k])])) { if (isset($_POST["filter" . strtolower($this->attrArray[$k])])) {
$value = " value=\"" . $_POST["filter" . strtolower($attr_array[$k])] . "\""; $value = " value=\"" . $_POST["filter" . strtolower($this->attrArray[$k])] . "\"";
} }
echo "<td>"; echo "<td>";
echo ("<input type=\"text\" size=15 name=\"filter" . strtolower ($attr_array[$k]) ."\"" . $value . ">"); echo ("<input type=\"text\" size=15 name=\"filter" . strtolower ($this->attrArray[$k]) ."\"" . $value . ">");
echo "</td>\n"; echo "</td>\n";
} }
echo "</tr>\n"; echo "</tr>\n";
} }
/** /**
* Manages all POST actions (e.g. button pressed) for the account lists. * Prints the entry list
* *
* @param string $scope account type * @param array $info entries
*/ */
function listDoPost($scope) { function listPrintTableBody($info) {
// calculate which rows to show
$table_begin = ($this->page - 1) * $this->maxPageEntries;
if (($this->page * $this->maxPageEntries) > sizeof($info)) $table_end = sizeof($info);
else $table_end = ($this->page * $this->maxPageEntries);
// print account list
for ($i = $table_begin; $i < $table_end; $i++) {
echo("<tr class=\"" . $this->type . "list\" onMouseOver=\"list_over(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" .
" onMouseOut=\"list_out(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" .
" onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" .
" onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=" . $this->type . "&amp;DN=" . $info[$i]['dn'] . "'\">\n");
if (isset($_GET['selectall'])) {
echo " <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"" .
" type=\"checkbox\" checked name=\"" . $info[$i]['LAM_ID'] . "\"></td>\n";
}
else {
echo " <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"" .
" type=\"checkbox\" name=\"" . $info[$i]['LAM_ID'] . "\"></td>\n";
}
echo (" <td align='center'><a href=\"../account/edit.php?type=" . $this->type . "&amp;DN='" . $info[$i]['dn'] . "'\">" . _("Edit") . "</a></td>\n");
for ($k = 0; $k < sizeof($this->attrArray); $k++) {
echo ("<td>");
// print all attribute entries seperated by "; "
$attrName = strtolower($this->attrArray[$k]);
if (isset($info[$i][$attrName]) && sizeof($info[$i][$attrName]) > 0) {
// delete "count" entry
unset($info[$i][$attrName]['count']);
if (is_array($info[$i][$attrName])) {
// sort array
sort($info[$i][$attrName]);
echo implode("; ", $info[$i][$attrName]);
}
else echo $info[$i][$attrName];
}
echo ("</td>\n");
}
echo("</tr>\n");
}
// display select all link
$colspan = sizeof($this->attrArray) + 1;
echo "<tr class=\"" . $this->type . "list\">\n";
echo "<td align=\"center\"><img src=\"../../graphics/select.png\" alt=\"select all\"></td>\n";
echo "<td colspan=$colspan>&nbsp;<a href=\"list.php?type=" . $this->type . "&amp;norefresh=y&amp;page=" . $this->page .
"&amp;sort=" . $this->sortColumn . $this->filterText . "&amp;selectall=yes\">" .
"<font color=\"black\"><b>" . _("Select all") . "</b></font></a></td>\n";
echo "</tr>\n";
echo ("</table>");
echo ("<br>");
}
/**
* Manages all POST actions (e.g. button pressed) for the account lists.
*/
function listDoPost() {
// check if button was pressed and if we have to add/delete an account // check if button was pressed and if we have to add/delete an account
if (isset($_POST['new']) || isset($_POST['del']) || isset($_POST['pdf']) || isset($_POST['pdf_all'])){ if (isset($_POST['new']) || isset($_POST['del']) || isset($_POST['pdf']) || isset($_POST['pdf_all'])){
// add new account // add new account
if (isset($_POST['new'])){ if (isset($_POST['new'])){
metaRefresh("../account/edit.php?type=" . $scope); metaRefresh("../account/edit.php?type=" . $this->type);
exit; exit;
} }
// delete account(s) // delete account(s)
@ -248,10 +414,10 @@ function listDoPost($scope) {
$accounts = array_keys($_POST, "on"); $accounts = array_keys($_POST, "on");
$_SESSION['delete_dn'] = array(); $_SESSION['delete_dn'] = array();
for ($i = 0; $i < sizeof($accounts); $i++) { for ($i = 0; $i < sizeof($accounts); $i++) {
$_SESSION['delete_dn'][] = $_SESSION[$scope . 'info'][$accounts[$i]]['dn']; $_SESSION['delete_dn'][] = $_SESSION[$this->type . 'info'][$accounts[$i]]['dn'];
} }
if (sizeof($accounts) > 0) { if (sizeof($accounts) > 0) {
metaRefresh("../delete.php?type=" . $scope); metaRefresh("../delete.php?type=" . $this->type);
exit; exit;
} }
} }
@ -263,8 +429,8 @@ function listDoPost($scope) {
$list = array(); $list = array();
// load accounts from LDAP // load accounts from LDAP
for ($i = 0; $i < sizeof($accounts); $i++) { for ($i = 0; $i < sizeof($accounts); $i++) {
$_SESSION["accountPDF-$i"] = new accountContainer($scope, "accountPDF-$i"); $_SESSION["accountPDF-$i"] = new accountContainer($this->type, "accountPDF-$i");
$_SESSION["accountPDF-$i"]->load_account($_SESSION[$scope . 'info'][$accounts[$i]]['dn']); $_SESSION["accountPDF-$i"]->load_account($_SESSION[$this->type . 'info'][$accounts[$i]]['dn']);
$list[$i] = $_SESSION["accountPDF-$i"]; $list[$i] = $_SESSION["accountPDF-$i"];
} }
if (sizeof($list) > 0) { if (sizeof($list) > 0) {
@ -275,9 +441,9 @@ function listDoPost($scope) {
// PDF for all accounts // PDF for all accounts
elseif (isset($_POST['pdf_all'])){ elseif (isset($_POST['pdf_all'])){
$list = array(); $list = array();
for ($i = 0; $i < sizeof($_SESSION[$scope . 'info']); $i++) { for ($i = 0; $i < sizeof($_SESSION[$this->type . 'info']); $i++) {
$_SESSION["accountPDF-$i"] = new accountContainer($scope, "accountPDF-$i"); $_SESSION["accountPDF-$i"] = new accountContainer($this->type, "accountPDF-$i");
$_SESSION["accountPDF-$i"]->load_account($_SESSION[$scope . 'info'][$i]['dn']); $_SESSION["accountPDF-$i"]->load_account($_SESSION[$this->type . 'info'][$i]['dn']);
$list[$i] = $_SESSION["accountPDF-$i"]; $list[$i] = $_SESSION["accountPDF-$i"];
} }
if (sizeof($list) > 0) { if (sizeof($list) > 0) {
@ -288,69 +454,19 @@ function listDoPost($scope) {
} }
} }
/**
* Returns the LDAP attribute names and their description for the user list
*
* @param string $scope account type
* @return array list of LDAP attributes and descriptions
*/
function listGetAttributeArray($scope) {
switch ($scope) {
case 'user':
return array (
"uid" => _("User ID"),
"uidnumber" => _("UID number"),
"gidnumber" => _("GID number"),
"cn" => _("User name"),
"host" => _("Allowed hosts"),
"givenname" => _("First name"),
"sn" => _("Last name"),
"homedirectory" => _("Home directory"),
"loginshell" => _("Login shell"),
"mail" => _("E-Mail"),
"gecos" => _("Description")
);
break;
case 'group':
return array (
"cn" => _("Group name"),
"gidnumber" => _("GID number"),
"memberuid" => _("Group members"),
"member" => _("Group member DNs"),
"description" => _("Group description")
);
break;
case 'host':
return array (
"uid" => _("Host name"),
"cn" => _("Host name"),
"rid" => _("RID (Windows UID)"),
"description" => _("Host description"),
"uidnumber" => _("UID number"),
"gidnumber" => _("GID number")
);
break;
default:
return array();
break;
}
}
/** /**
* Prints a combobox with possible sub-DNs. * Prints a combobox with possible sub-DNs.
*
* @param array $units list of OUs
* @param string $suffix current LDAP suffix
*/ */
function listShowOUSelection($units, $suffix) { function listShowOUSelection() {
if (sizeof($units) > 1) { if (sizeof($this->possibleSuffixes) > 1) {
echo ("<p align=\"left\">\n"); echo ("<p align=\"left\">\n");
echo ("<b>" . _("Suffix") . ": </b>"); echo ("<b>" . _("Suffix") . ": </b>");
echo ("<select size=1 name=\"suffix\">\n"); echo ("<select size=1 name=\"suffix\">\n");
for ($i = 0; $i < sizeof($units); $i++) { for ($i = 0; $i < sizeof($this->possibleSuffixes); $i++) {
if ($suffix == $units[$i]) echo ("<option selected>" . $units[$i] . "</option>\n"); if ($this->suffix == $this->possibleSuffixes[$i]) {
else echo("<option>" . $units[$i] . "</option>\n"); echo ("<option selected>" . $this->possibleSuffixes[$i] . "</option>\n");
}
else echo("<option>" . $this->possibleSuffixes[$i] . "</option>\n");
} }
echo ("</select>\n"); echo ("</select>\n");
echo ("<input type=\"submit\" name=\"refresh\" value=\"" . _("Change suffix") . "\">"); echo ("<input type=\"submit\" name=\"refresh\" value=\"" . _("Change suffix") . "\">");
@ -358,6 +474,43 @@ function listShowOUSelection($units, $suffix) {
} }
} }
/**
* Prints the create, delete and PDF buttons.
*
* @param boolean $createOnly true if only the create button should be displayed
*/
function listPrintButtons($createOnly) {
// add/delete/PDF buttons
echo ("<input type=\"submit\" name=\"new\" value=\"" . $this->labels['newEntry'] . "\">\n");
if (!$createOnly) {
echo ("<input type=\"submit\" name=\"del\" value=\"" . $this->labels['deleteEntry'] . "\">\n");
echo ("<br><br><br>\n");
echo "<fieldset><legend><b>PDF</b></legend>\n";
echo ("<b>" . _('PDF structure') . ":</b>&nbsp;&nbsp;<select name=\"pdf_structure\">\n");
$pdf_structures = getPDFStructureDefinitions($this->type);
foreach($pdf_structures as $pdf_structure) {
echo "<option " . (($pdf_structure == 'default') ? " selected" : "") . ">" . $pdf_structure . "</option>";
}
echo "</select>&nbsp;&nbsp;&nbsp;&nbsp;\n";
echo ("<input type=\"submit\" name=\"pdf\" value=\"" . $this->labels['createPDF'] . "\">\n");
echo "&nbsp;";
echo ("<input type=\"submit\" name=\"pdf_all\" value=\"" . $this->labels['createPDFAll'] . "\">\n");
echo "</fieldset>";
}
}
/**
* Prints the HTML head.
*/
function listPrintHeader() {
echo $_SESSION['header'];
echo "<title>Account list</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/type_" . $this->type . ".css\">\n";
echo "</head><body>\n";
$this->listPrintJavaScript();
}
/** /**
* Prints JavaScript code needed for mouse-over effects. * Prints JavaScript code needed for mouse-over effects.
*/ */
@ -396,14 +549,13 @@ function listPrintJavaScript() {
* Returns an hash array containing with all attributes to be shown and their descriptions. * Returns an hash array containing with all attributes to be shown and their descriptions.
* Format: array(attribute => description) * Format: array(attribute => description)
* *
* @param string $scope account type
* @return array attribute list * @return array attribute list
*/ */
function listGetAttributeDescriptionList($scope) { function listGetAttributeDescriptionList() {
$ret = array(); $ret = array();
$attr_string = $_SESSION["config"]->get_listAttributes($scope); $attr_string = $_SESSION["config"]->get_listAttributes($this->type);
$temp_array = explode(";", $attr_string); $temp_array = explode(";", $attr_string);
$hash_table = listGetAttributeArray($scope); $hash_table = getListAttributeDescriptions($this->type);
// generate column attributes and descriptions // generate column attributes and descriptions
for ($i = 0; $i < sizeof($temp_array); $i++) { for ($i = 0; $i < sizeof($temp_array); $i++) {
// if value is predifined, look up description in hash_table // if value is predifined, look up description in hash_table
@ -430,5 +582,64 @@ function listGetAttributeDescriptionList($scope) {
return $ret; return $ret;
} }
/**
* Sets some internal parameters.
*/
function listGetParams() {
// get current page
if (isset($_GET["page"])) $this->page = $_GET["page"];
else $this->page = 1;
// generate attribute-description table
$temp_array = $this->listGetAttributeDescriptionList();
$this->attrArray = array_keys($temp_array); // list of LDAP attributes to show
$this->descArray = array_values($temp_array); // list of descriptions for the attributes
// get maximum count of entries shown on one page
if ($_SESSION["config"]->get_MaxListEntries() <= 0)
$this->maxPageEntries = 10; // default setting, if not yet set
else
$this->maxPageEntries = $_SESSION["config"]->get_MaxListEntries();
// get sorting column
if (isset($_GET["sort"])) $this->sortColumn = $_GET["sort"];
else $this->sortColumn = strtolower($this->attrArray[0]);
// check search suffix
if ($_POST['suffix']) $this->suffix = $_POST['suffix']; // new suffix selected via combobox
elseif (!$this->suffix) $this->suffix = $_SESSION["config"]->get_Suffix($this->type); // default suffix
// check if LDAP data should be refreshed
$this->refresh = true;
if (isset($_GET['norefresh'])) $this->refresh = false;
if (isset($_POST['refresh'])) $this->refresh = true;
}
/**
* Rereads the entries from LDAP.
*/
function listRefreshData() {
// configure search filter
$module_filter = get_ldap_filter($this->type); // basic filter is provided by modules
$filter = "(&" . $module_filter . ")";
$attrs = $this->attrArray;
$sr = @ldap_search($_SESSION["ldap"]->server(), $this->suffix, $filter, $attrs);
if (ldap_errno($_SESSION["ldap"]->server()) == 4) {
StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem."));
}
if ($sr) {
$info = ldap_get_entries($_SESSION["ldap"]->server, $sr);
ldap_free_result($sr);
// delete first array entry which is "count"
unset($info['count']);
// save position in original $info
for ($i = 0; $i < sizeof($info); $i++) $info[$i]['LAM_ID'] = $i;
// save results
$this->entries = $info;
}
else {
$this->entries = array();
StatusMessage("ERROR", _("LDAP Search failed! Please check your preferences."), $this->labels['error_noneFound']); // TODO correct message
}
// generate list of possible suffixes
$this->possibleSuffixes = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($this->type));
}
}
?> ?>

View File

@ -317,6 +317,11 @@ function getConfigOptions($scopes) {
*/ */
function getConfigDescriptions() { function getConfigDescriptions() {
$return = array('legend' => array(), 'descriptions' => array()); $return = array('legend' => array(), 'descriptions' => array());
$modules = array();
$types = $_SESSION['config']->get_ActiveTypes();
for ($i = 0; $i < sizeof($types); $i++) {
$modules = array_merge($modules, getAvailableModules($types[$i]));
}
$modules = array_merge(getAvailableModules('user'), getAvailableModules('group'), getAvailableModules('host')); $modules = array_merge(getAvailableModules('user'), getAvailableModules('group'), getAvailableModules('host'));
$modules = array_values(array_unique($modules)); $modules = array_values(array_unique($modules));
for ($i = 0; $i < sizeof($modules); $i++) { for ($i = 0; $i < sizeof($modules); $i++) {
@ -375,15 +380,6 @@ function getAvailablePDFFields($scope) {
return $return; return $return;
} }
/**
* Return a list of current available scopes
*
* @return array Available scopes
*/
function getAvailableScopes() {
return array('user','group','host', 'domain');
}
/** /**
* Returns an array containing all input columns for the file upload. * Returns an array containing all input columns for the file upload.
* *
@ -707,8 +703,6 @@ class accountContainer {
if (!is_string($type)) trigger_error('Argument of accountContainer must be string.', E_USER_ERROR); if (!is_string($type)) trigger_error('Argument of accountContainer must be string.', E_USER_ERROR);
if (!is_string($base)) trigger_error('Argument of accountContainer must be string.', E_USER_ERROR); if (!is_string($base)) trigger_error('Argument of accountContainer must be string.', E_USER_ERROR);
// *** fixme use global variable to determine allowed types
if (!in_array($type, getAvailableScopes())) trigger_error('Account type not recognized.', E_USER_ERROR);
$this->type = $type; $this->type = $type;
$this->base = $base; $this->base = $base;
// Set startpage // Set startpage
@ -900,6 +894,7 @@ class accountContainer {
else echo _("Create new Account"); else echo _("Create new Account");
echo "</title>\n"; echo "</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n"; echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/type_" . $this->type . ".css\">\n";
echo "</head><body>\n"; echo "</head><body>\n";
echo "<form enctype=\"multipart/form-data\" action=\"edit.php\" method=\"post\">\n"; echo "<form enctype=\"multipart/form-data\" action=\"edit.php\" method=\"post\">\n";
// Display error-messages // Display error-messages
@ -937,7 +932,7 @@ class accountContainer {
echo "<fieldset class=\"".$this->type."edit\"><legend><b>"; echo "<fieldset class=\"".$this->type."edit\"><legend><b>";
echo _('Please select page:'); echo _('Please select page:');
echo "</b></legend>\n"; echo "</b></legend><center>\n";
// calculate button width // calculate button width
$buttonWidth = round(0.8 * strlen(utf8_decode(_("Reset changes")))); $buttonWidth = round(0.8 * strlen(utf8_decode(_("Reset changes"))));
for ($b = 0; $b < sizeof($this->order); $b++) { for ($b = 0; $b < sizeof($this->order); $b++) {
@ -971,7 +966,7 @@ class accountContainer {
if ($this->subpage == 'finish') echo " disabled"; if ($this->subpage == 'finish') echo " disabled";
echo "><br>\n"; echo "><br>\n";
} }
echo "</fieldset>\n"; echo "</center></fieldset>\n";
echo "</td>\n<td>"; echo "</td>\n<td>";
if ($this->current_page==0) { if ($this->current_page==0) {
echo "<fieldset class=\"".$this->type."edit\"><legend><b>"; echo "<fieldset class=\"".$this->type."edit\"><legend><b>";
@ -1177,7 +1172,7 @@ class accountContainer {
$string = trim($string); $string = trim($string);
// Add must // Add must
foreach (explode(" $ ", $string) as $attribute) { foreach (explode(" $ ", $string) as $attribute) {
$return[$attribute] = array(''); $return[$attribute] = array();
} }
} }
elseif (strpos($_SESSION['ldap']->objectClasses[$line], 'MUST ')) { elseif (strpos($_SESSION['ldap']->objectClasses[$line], 'MUST ')) {
@ -1186,7 +1181,7 @@ class accountContainer {
$string = substr($string_withtail, 0, strpos($string_withtail, ' ')); $string = substr($string_withtail, 0, strpos($string_withtail, ' '));
$string = trim($string); $string = trim($string);
// Add must // Add must
$return[$string] = array(''); $return[$string] = array();
} }
// create array with may-attributes // create array with may-attributes
// Get startposition in string // Get startposition in string
@ -1197,7 +1192,7 @@ class accountContainer {
$string = trim($string); $string = trim($string);
// Add may // Add may
foreach (explode(" $ ", $string) as $attribute) { foreach (explode(" $ ", $string) as $attribute) {
$return[$attribute] = array(''); $return[$attribute] = array();
} }
} }
elseif (strpos($_SESSION['ldap']->objectClasses[$line], 'MAY ')) { elseif (strpos($_SESSION['ldap']->objectClasses[$line], 'MAY ')) {
@ -1206,7 +1201,7 @@ class accountContainer {
$string = substr($string_withtail, 0, strpos($string_withtail, ' ')); $string = substr($string_withtail, 0, strpos($string_withtail, ' '));
$string = trim($string); $string = trim($string);
// Add must // Add must
$return[$string] = array(''); $return[$string] = array();
} }
// Get attributes of subclasses // Get attributes of subclasses
while (strpos($_SESSION['ldap']->objectClasses[$line], "SUP ")) { while (strpos($_SESSION['ldap']->objectClasses[$line], "SUP ")) {
@ -1227,7 +1222,7 @@ class accountContainer {
$string = trim($string); $string = trim($string);
// Add must // Add must
foreach (explode(" $ ", $string) as $attribute) { foreach (explode(" $ ", $string) as $attribute) {
$return[$attribute] = array(''); $return[$attribute] = array();
} }
} }
elseif (strpos($_SESSION['ldap']->objectClasses[$line], 'MUST ')) { elseif (strpos($_SESSION['ldap']->objectClasses[$line], 'MUST ')) {
@ -1236,7 +1231,7 @@ class accountContainer {
$string = substr($string_withtail, 0, strpos($string_withtail, ' ')); $string = substr($string_withtail, 0, strpos($string_withtail, ' '));
$string = trim($string); $string = trim($string);
// Add must // Add must
$return[$string] = array(''); $return[$string] = array();
} }
// create array with may-attributes // create array with may-attributes
// Get startposition in string // Get startposition in string
@ -1247,7 +1242,7 @@ class accountContainer {
$string = trim($string); $string = trim($string);
// Add may // Add may
foreach (explode(" $ ", $string) as $attribute) { foreach (explode(" $ ", $string) as $attribute) {
$return[$attribute] = array(''); $return[$attribute] = array();
} }
} }
elseif (strpos($_SESSION['ldap']->objectClasses[$line], 'MAY ')) { elseif (strpos($_SESSION['ldap']->objectClasses[$line], 'MAY ')) {
@ -1256,7 +1251,7 @@ class accountContainer {
$string = substr($string_withtail, 0, strpos($string_withtail, ' ')); $string = substr($string_withtail, 0, strpos($string_withtail, ' '));
$string = trim($string); $string = trim($string);
// Add must // Add must
$return[$string] = array(''); $return[$string] = array();
} }
} }

View File

@ -45,7 +45,7 @@ class nisMailAlias extends baseModule {
function get_metaData() { function get_metaData() {
$return = array(); $return = array();
// manages host accounts // manages host accounts
$return["account_types"] = array("group"); $return["account_types"] = array("mailAlias");
// base module // base module
$return["is_base"] = true; $return["is_base"] = true;
// LDAP filter // LDAP filter

View File

@ -832,7 +832,7 @@ class posixGroup extends baseModule {
$DNs = array_keys($result); $DNs = array_keys($result);
for ($i=0; $i<count($DNs); $i++) { for ($i=0; $i<count($DNs); $i++) {
// Get Domain SID from name // Get Domain SID from name
$sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); $sambaDomains = search_domains();
// Get Domain-SID from group SID // Get Domain-SID from group SID
$domainSID = substr($result[$DNs[$i]], 0, strrpos($result[$DNs[$i]], "-")); $domainSID = substr($result[$DNs[$i]], 0, strrpos($result[$DNs[$i]], "-"));
for ($i=0; $i<count($sambaDomains); $i++ ) for ($i=0; $i<count($sambaDomains); $i++ )

View File

@ -0,0 +1,428 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 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
*/
/**
* Manages Samba 3 domain entries.
*
* @package modules
* @author Roland Gruber
*/
/**
* Manages Samba 3 domain entries.
*
* @package modules
*/
class sambaDomain extends baseModule {
/**
* Returns meta data that is interpreted by parent class
*
* @return array array with meta data
*/
function get_metaData() {
$return = array();
// manages host accounts
$return["account_types"] = array("smbDomain");
// alias name
$return["alias"] = _("Samba domain");
// this is a base module
$return["is_base"] = true;
// RDN attribute
$return["RDN"] = array("sambaDomainName" => "high");
// LDAP filter
$return["ldap_filter"] = array('or' => "(objectClass=sambaDomain)");
// module dependencies
$return['dependencies'] = array('depends' => array(), 'conflicts' => array());
// help Entries
$return['help'] = array(
'domainName' => array(
"Headline" => _("Domain name"),
"Text" => _("The name of your Windows domain or workgroup.")
),
'domainSID' => array(
"Headline" => _("Domain SID"),
"Text" => _("The SID of your Samba server. Get it with \"net getlocalsid\".")
),
'nextRID' => array(
"Headline" => _("Next RID"),
"Text" => _("Next RID to use when creating accounts (only used by Winbind).")
),
'nextUserRID' => array(
"Headline" => _("Next user RID"),
"Text" => _("Next RID to use when creating user accounts (only used by Winbind).")
),
'nextGroupRID' => array(
"Headline" => _("Next group RID"),
"Text" => _("Next RID to use when creating group accounts (only used by Winbind).")
),
'nextRID' => array(
"Headline" => _("RID base"),
"Text" => _("Used for calculating RIDs from UID/GID. Do not change if unsure.")
));
// upload fields
$return['upload_columns'] = array(
array(
'name' => 'sambaDomain_domainName',
'description' => _('Domain name'),
'help' => 'domainName',
'example' => _('Workgroup'),
'required' => true
),
array(
'name' => 'sambaDomain_domainSID',
'description' => _('Domain SID'),
'help' => 'domainSID',
'example' => 'S-1-1-22-123-123-123',
'required' => true
),
array(
'name' => 'sambaDomain_RIDbase',
'description' => _('RID base'),
'help' => 'RIDbase',
'example' => '1000',
'default' => 1000
),
array(
'name' => 'sambaDomain_nextRID',
'description' => _('Next RID'),
'help' => 'nextRID',
'example' => '12345'
),
array(
'name' => 'sambaDomain_nextUserRID',
'description' => _('Next user RID'),
'help' => 'nextUserRID',
'example' => '12345'
),
array(
'name' => 'sambaDomain_nextGroupRID',
'description' => _('Next group RID'),
'help' => 'nextGroupRID',
'example' => '12345'
)
);
// available PDF fields
$return['PDF_fields'] = array(
'domainName', 'domainSID', 'nextRID',
'nextUserRID', 'nextGroupRID', 'RIDbase'
);
return $return;
}
/**
* This function fills the error message array with messages
*/
function load_Messages() {
$this->messages['domainName'][0] = array('ERROR', _('Domain name is invalid!'));
$this->messages['domainName'][1] = array('ERROR', _('Account %s:') . ' sambaDomain_domainName', _('Domain name is invalid!'));
$this->messages['domainSID'][0] = array('ERROR', _('Samba 3 domain SID is invalid!'));
$this->messages['domainSID'][1] = array('ERROR', _('Account %s:') . ' sambaDomain_domainSID', _('Samba 3 domain SID is invalid!'));
$this->messages['nextRID'][0] = array('ERROR', _('Next RID is not a number!'));
$this->messages['nextRID'][1] = array('ERROR', _('Account %s:') . ' sambaDomain_nextRID', _('Next RID is not a number!'));
$this->messages['nextUserRID'][0] = array('ERROR', _('Next user RID is not a number!'));
$this->messages['nextUserRID'][1] = array('ERROR', _('Account %s:') . ' sambaDomain_nextUserRID', _('Next user RID is not a number!'));
$this->messages['nextGroupRID'][0] = array('ERROR', _('Next group RID is not a number!'));
$this->messages['nextGroupRID'][1] = array('ERROR', _('Account %s:') . ' sambaDomain_nextGroupRID', _('Next group RID is not a number!'));
$this->messages['RIDbase'][0] = array('ERROR', _('Algorithmic RID base is not a number!'));
$this->messages['RIDbase'][1] = array('ERROR', _('Account %s:') . ' sambaDomain_RIDbase', _('Algorithmic RID base is not a number!'));
}
/**
* This function loads all needed attributes into the object.
*
* @param array $attr an array as it is retured from ldap_get_attributes
*/
function load_attributes($attr) {
$attributes = array('sambaAlgorithmicRidBase', 'sambaDomainName', 'sambaNextGroupRid',
'sambaNextRid', 'sambaNextUserRid', 'sambaSID');
$this->attributes['objectClass'] = array();
$this->attributes['macAddress'] = array();
$this->orig['objectClass'] = array();
$this->orig['macAddress'] = array();
if (isset($attr['objectClass'])) {
$this->attributes['objectClass'] = $attr['objectClass'];
$this->orig['objectClass'] = $attr['objectClass'];
}
for ($i = 0; $i < sizeof($attributes); $i++) {
if (isset($attr[$attributes[$i]])) {
$this->attributes[$attributes[$i]] = $attr[$attributes[$i]];
$this->orig[$attributes[$i]] = $attr[$attributes[$i]];
}
}
// add object class if needed
if (! in_array('sambaDomain', $this->orig['objectClass'])) {
$this->attributes['objectClass'][] = 'sambaDomain';
}
return 0;
}
/**
* Returns a list of modifications which have to be made to the LDAP account.
*
* @return array list of modifications
* <br>This function returns an array with 3 entries:
* <br>array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr)), DN2 .... )
* <br>DN is the DN to change. It may be possible to change several DNs (e.g. create a new user and add him to some groups via attribute memberUid)
* <br>"add" are attributes which have to be added to LDAP entry
* <br>"remove" are attributes which have to be removed from LDAP entry
* <br>"modify" are attributes which have to been modified in LDAP entry
*/
function save_attributes() {
return $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig);
}
/**
* This function will create the meta HTML code to show a page with all attributes.
*
* @param array $post HTTP-POST values
*/
function display_html_attributes(&$post) {
$return = array();
// domain name
if ($_SESSION[$this->base]->isNewAccount) {
$return[] = array(
0 => array('kind' => 'text', 'text' => _('Domain name').'*'),
1 => array('kind' => 'input', 'name' => 'domainName', 'type' => 'text', 'value' => $this->attributes['sambaDomainName'][0]),
2 => array('kind' => 'help', 'value' => 'domainName'));
}
else {
$return[] = array(
0 => array('kind' => 'text', 'text' => _('Domain name')),
1 => array('kind' => 'text', 'text' => $this->attributes['sambaDomainName'][0]),
2 => array('kind' => 'help', 'value' => 'domainName'));
}
// domain SID
if ($_SESSION[$this->base]->isNewAccount) {
$return[] = array(
0 => array('kind' => 'text', 'text' => _('Domain SID').'*'),
1 => array('kind' => 'input', 'name' => 'domainSID', 'type' => 'text', 'value' => $this->attributes['sambaSID'][0]),
2 => array('kind' => 'help', 'value' => 'domainSID'));
}
else {
$return[] = array(
0 => array('kind' => 'text', 'text' => _('Domain SID')),
1 => array('kind' => 'text', 'text' => $this->attributes['sambaSID'][0]),
2 => array('kind' => 'help', 'value' => 'domainSID'));
}
// next RID
$return[] = array(
0 => array('kind' => 'text', 'text' => _('Next RID')),
1 => array('kind' => 'input', 'name' => 'nextRID', 'type' => 'text', 'value' => $this->attributes['sambaNextRid'][0]),
2 => array('kind' => 'help', 'value' => 'nextRID'));
// next user RID
$return[] = array(
0 => array('kind' => 'text', 'text' => _('Next user RID')),
1 => array('kind' => 'input', 'name' => 'nextUserRID', 'type' => 'text', 'value' => $this->attributes['sambaNextUserRid'][0]),
2 => array('kind' => 'help', 'value' => 'nextUserRID'));
// next group RID
$return[] = array(
0 => array('kind' => 'text', 'text' => _('Next group RID')),
1 => array('kind' => 'input', 'name' => 'nextGroupRID', 'type' => 'text', 'value' => $this->attributes['sambaNextGroupRid'][0]),
2 => array('kind' => 'help', 'value' => 'nextGroupRID'));
// RID base
if (!isset($this->attributes['sambaAlgorithmicRidBase'][0])) $this->attributes['sambaAlgorithmicRidBase'][0] = 1000;
if ($_SESSION[$this->base]->isNewAccount) {
$return[] = array(
0 => array('kind' => 'text', 'text' => _('RID base').'*'),
1 => array('kind' => 'input', 'name' => 'RIDbase', 'type' => 'text', 'value' => $this->attributes['sambaAlgorithmicRidBase'][0]),
2 => array('kind' => 'help', 'value' => 'RIDbase'));
}
else {
$return[] = array(
0 => array('kind' => 'text', 'text' => _('RID base')),
1 => array('kind' => 'text', 'text' => $this->attributes['sambaAlgorithmicRidBase'][0]),
2 => array('kind' => 'help', 'value' => 'RIDbase'));
}
return $return;
}
/**
* Processes user input of the primary module page.
* It checks if all input values are correct and updates the associated LDAP attributes.
*
* @param array $post HTTP-POST values
* @return array list of info/error messages
*/
function process_attributes(&$post) {
$errors = array();
if ($_SESSION[$this->base]->isNewAccount) {
// domain SID
if (!get_preg($_POST['domainSID'], 'domainSID')) {
$errors[] = $this->messages['domainSID'][0];
}
else {
$this->attributes['sambaSID'][0] = $_POST['domainSID'];
}
// RID base
if (!get_preg($_POST['RIDbase'], 'digit') && !($_POST['RIDbase'] == '')) {
$errors[] = $this->messages['RIDbase'][0];
}
else {
$this->attributes['sambaAlgorithmicRidBase'][0] = $_POST['RIDbase'];
}
// domain name
if (!get_preg($_POST['domainName'], 'domainname') && !($_POST['domainName'] == '')) {
$errors[] = $this->messages['domainName'][0];
}
else {
$this->attributes['sambaDomainName'][0] = $_POST['domainName'];
}
}
// next RID
if (!get_preg($_POST['nextRID'], 'digit')) {
$errors[] = $this->messages['nextRID'][0];
}
else {
$this->attributes['sambaNextRid'][0] = $_POST['nextRID'];
}
// next user RID
if (!get_preg($_POST['nextUserRID'], 'digit')) {
$errors[] = $this->messages['nextUserRID'][0];
}
else {
$this->attributes['sambaNextUserRid'][0] = $_POST['nextUserRID'];
}
// next group RID
if (!get_preg($_POST['nextGroupRID'], 'digit')) {
$errors[] = $this->messages['nextGroupRID'][0];
}
else {
$this->attributes['sambaNextGroupRid'][0] = $_POST['nextGroupRID'];
}
return $errors;
}
/**
* In this function the LDAP account is built up.
*
* @param array $rawAccounts list of hash arrays (name => value) from user input
* @param array $partialAccounts list of hash arrays (name => value) which are later added to LDAP
* @param array $ids list of IDs for column position (e.g. "posixAccount_uid" => 5)
* @return array list of error messages if any
*/
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
$messages = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class
if (!in_array("sambaDomain", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "sambaDomain";
// domain name
if (get_preg($rawAccounts[$i][$ids['sambaDomain_domainName']], 'domainname')) {
$partialAccounts[$i]['sambaDomainName'] = $rawAccounts[$i][$ids['sambaDomain_domainName']];
}
else {
$errMsg = $this->messages['domainName'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
// domain SID
if (get_preg($rawAccounts[$i][$ids['sambaDomain_domainSID']], 'domainSID')) {
$partialAccounts[$i]['sambaSID'] = $rawAccounts[$i][$ids['sambaDomain_domainSID']];
}
else {
$errMsg = $this->messages['domainSID'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
// RID base
if ($rawAccounts[$i][$ids['sambaDomain_RIDbase']]) {
if (get_preg($rawAccounts[$i][$ids['sambaDomain_RIDbase']], 'digit')) {
$partialAccounts[$i]['sambaAlgorithmicRidBase'] = $rawAccounts[$i][$ids['sambaDomain_RIDbase']];
}
else {
$errMsg = $this->messages['RIDbase'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
}
else {
$partialAccounts[$i]['sambaAlgorithmicRidBase'] = '1000';
}
// next RID
if ($rawAccounts[$i][$ids['sambaDomain_nextRID']]) {
if (get_preg($rawAccounts[$i][$ids['sambaDomain_nextRID']], 'digit')) {
$partialAccounts[$i]['sambaNextRid'] = $rawAccounts[$i][$ids['sambaDomain_nextRID']];
}
else {
$errMsg = $this->messages['nextRID'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
}
// next user RID
if ($rawAccounts[$i][$ids['sambaDomain_nextUserRID']]) {
if (get_preg($rawAccounts[$i][$ids['sambaDomain_nextUserRID']], 'digit')) {
$partialAccounts[$i]['sambaNextUserRid'] = $rawAccounts[$i][$ids['sambaDomain_nextUserRID']];
}
else {
$errMsg = $this->messages['nextUserRID'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
}
// next group RID
if ($rawAccounts[$i][$ids['sambaDomain_nextGroupRID']]) {
if (get_preg($rawAccounts[$i][$ids['sambaDomain_nextGroupRID']], 'digit')) {
$partialAccounts[$i]['sambaNextGroupRid'] = $rawAccounts[$i][$ids['sambaDomain_nextGroupRID']];
}
else {
$errMsg = $this->messages['nextGroupRID'][1];
array_push($errMsg, array($i));
$messages[] = $errMsg;
}
}
}
return $messages;
}
/**
* Returns the PDF entries for this module.
*
* @return array list of possible PDF entries
*/
function get_pdfEntries() {
$return = array();
if (sizeof($this->attributes['sambaDomainName']) > 0) {
$return['sambaDomain_domainName'][0] = '<block><key>' . _('Domain name') . '</key><value>' . implode(', ', $this->attributes['sambaDomainName']) . '</value></block>';
}
if (sizeof($this->attributes['sambaSID']) > 0) {
$return['sambaDomain_domainSID'][0] = '<block><key>' . _('Domain SID') . '</key><value>' . implode(', ', $this->attributes['sambaSID']) . '</value></block>';
}
if (sizeof($this->attributes['sambaNextRid']) > 0) {
$return['sambaDomain_nextRID'][0] = '<block><key>' . _('Next RID') . '</key><value>' . implode(', ', $this->attributes['sambaNextRid']) . '</value></block>';
}
if (sizeof($this->attributes['sambaNextUserRid']) > 0) {
$return['sambaDomain_nextUserRID'][0] = '<block><key>' . _('Next user RID') . '</key><value>' . implode(', ', $this->attributes['sambaNextUserRid']) . '</value></block>';
}
if (sizeof($this->attributes['sambaNextGroupRid']) > 0) {
$return['sambaDomain_nextGroupRID'][0] = '<block><key>' . _('Next group RID') . '</key><value>' . implode(', ', $this->attributes['sambaNextGroupRid']) . '</value></block>';
}
if (sizeof($this->attributes['sambaAlgorithmicRidBase']) > 0) {
$return['sambaDomain_RIDbase'][0] = '<block><key>' . _('RID base') . '</key><value>' . implode(', ', $this->attributes['sambaAlgorithmicRidBase']) . '</value></block>';
}
return $return;
}
}
?>

View File

@ -83,7 +83,7 @@ class sambaGroupMapping extends baseModule {
function init($base) { function init($base) {
// call parent init // call parent init
parent::init($base); parent::init($base);
$sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); $sambaDomains = search_domains();
if (sizeof($sambaDomains) == 0) { if (sizeof($sambaDomains) == 0) {
StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), ''); StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), '');
return; return;
@ -100,7 +100,7 @@ class sambaGroupMapping extends baseModule {
*/ */
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
// search existing Samba 3 domains // search existing Samba 3 domains
$domains = search_domains($_SESSION['config']->get_Suffix('domain')); $domains = search_domains();
$nameToSID = array(); $nameToSID = array();
// get domain SIDs // get domain SIDs
for ($i = 0; $i < sizeof($domains); $i++) { for ($i = 0; $i < sizeof($domains); $i++) {
@ -168,7 +168,7 @@ class sambaGroupMapping extends baseModule {
* It will output a complete html-table * It will output a complete html-table
*/ */
function display_html_attributes(&$post) { function display_html_attributes(&$post) {
$sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); $sambaDomains = search_domains();
if (sizeof($sambaDomains) == 0) { if (sizeof($sambaDomains) == 0) {
StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), ''); StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), '');
return; return;
@ -243,7 +243,7 @@ class sambaGroupMapping extends baseModule {
// upload fields // upload fields
// search existing Samba 3 domains // search existing Samba 3 domains
if ($_SESSION['loggedIn']) { if ($_SESSION['loggedIn']) {
$domains = search_domains($_SESSION['config']->get_Suffix('domain')); $domains = search_domains();
$domainNames = array(); $domainNames = array();
for ($i = 0; $i < sizeof($domains); $i++) $domainNames[] = $domains[$i]->name; for ($i = 0; $i < sizeof($domains); $i++) $domainNames[] = $domains[$i]->name;
$return['upload_columns'] = array( $return['upload_columns'] = array(
@ -327,7 +327,7 @@ class sambaGroupMapping extends baseModule {
function get_profileOptions() { function get_profileOptions() {
$return = array(); $return = array();
// get list of domains // get list of domains
$sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); $sambaDomains = search_domains();
$sambaDomainNames = array(); $sambaDomainNames = array();
for ($i = 0; $i < count($sambaDomains); $i++ ) { for ($i = 0; $i < count($sambaDomains); $i++ ) {
// extract names // extract names
@ -350,7 +350,7 @@ class sambaGroupMapping extends baseModule {
function load_profile($profile) { function load_profile($profile) {
if (isset($profile['sambaGroupMapping_sambaDomainName'][0])) { if (isset($profile['sambaGroupMapping_sambaDomainName'][0])) {
// get list of domains // get list of domains
$sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); $sambaDomains = search_domains();
for ($i = 0; $i < sizeof($sambaDomains); $i++) { for ($i = 0; $i < sizeof($sambaDomains); $i++) {
if ($sambaDomains[$i]->name == $profile['sambaGroupMapping_sambaDomainName'][0]) { if ($sambaDomains[$i]->name == $profile['sambaGroupMapping_sambaDomainName'][0]) {
$this->attributes['sambaSID'][0] = $sambaDomains[$i]->SID . "-0"; $this->attributes['sambaSID'][0] = $sambaDomains[$i]->SID . "-0";
@ -394,7 +394,7 @@ class sambaGroupMapping extends baseModule {
* @return array list of info/error messages * @return array list of info/error messages
*/ */
function process_attributes(&$post) { function process_attributes(&$post) {
$sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); $sambaDomains = search_domains();
if (sizeof($sambaDomains) == 0) { if (sizeof($sambaDomains) == 0) {
return array(array(array("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.')))); return array(array(array("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'))));
} }
@ -448,7 +448,7 @@ class sambaGroupMapping extends baseModule {
*/ */
function save_attributes() { function save_attributes() {
// Get Domain SID from name // Get Domain SID from name
$sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); $sambaDomains = search_domains();
// Get Domain-SID from group SID // Get Domain-SID from group SID
$domainSID = substr($this->attributes['sambaSID'][0], 0, strrpos($this->attributes['sambaSID'][0], "-")); $domainSID = substr($this->attributes['sambaSID'][0], 0, strrpos($this->attributes['sambaSID'][0], "-"));
for ($i=0; $i<count($sambaDomains); $i++ ) for ($i=0; $i<count($sambaDomains); $i++ )

View File

@ -416,7 +416,7 @@ class sambaSamAccount extends baseModule {
$this->noexpire = true; $this->noexpire = true;
$this->nopwd = false; $this->nopwd = false;
$this->deactivated = false; $this->deactivated = false;
$sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); $sambaDomains = search_domains();
if (sizeof($sambaDomains) == 0) { if (sizeof($sambaDomains) == 0) {
StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), ''); StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), '');
return; return;
@ -468,7 +468,7 @@ class sambaSamAccount extends baseModule {
* it's psssible uidNumber has changed * it's psssible uidNumber has changed
*/ */
// Get Domain SID from name // Get Domain SID from name
$sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); $sambaDomains = search_domains();
for ($i=0; $i<count($sambaDomains); $i++ ) { for ($i=0; $i<count($sambaDomains); $i++ ) {
if ($this->attributes['sambaDomainName'][0] == $sambaDomains[$i]->name) { if ($this->attributes['sambaDomainName'][0] == $sambaDomains[$i]->name) {
$SID = $sambaDomains[$i]->SID; $SID = $sambaDomains[$i]->SID;
@ -493,7 +493,7 @@ class sambaSamAccount extends baseModule {
* @return array list of info/error messages * @return array list of info/error messages
*/ */
function process_attributes(&$post) { function process_attributes(&$post) {
$sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); $sambaDomains = search_domains();
if (sizeof($sambaDomains) == 0) { if (sizeof($sambaDomains) == 0) {
return array(array(array("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.')))); return array(array(array("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'))));
} }
@ -739,7 +739,7 @@ class sambaSamAccount extends baseModule {
*/ */
function display_html_attributes(&$post) { function display_html_attributes(&$post) {
// Get Domain SID from user SID // Get Domain SID from user SID
$sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); $sambaDomains = search_domains();
if (sizeof($sambaDomains) == 0) { if (sizeof($sambaDomains) == 0) {
StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), ''); StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), '');
return; return;
@ -1073,7 +1073,7 @@ class sambaSamAccount extends baseModule {
2 => array('kind' => 'help', 'value' => 'workstations') 2 => array('kind' => 'help', 'value' => 'workstations')
); );
// domains // domains
$sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); $sambaDomains = search_domains();
$sambaDomainNames = array(); $sambaDomainNames = array();
for ($i = 0; $i < count($sambaDomains); $i++) { for ($i = 0; $i < count($sambaDomains); $i++) {
$sambaDomainNames[] = $sambaDomains[$i]->name; $sambaDomainNames[] = $sambaDomains[$i]->name;
@ -1092,7 +1092,7 @@ class sambaSamAccount extends baseModule {
} }
elseif ($this->get_scope() == 'host') { elseif ($this->get_scope() == 'host') {
// domains // domains
$sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); $sambaDomains = search_domains();
$sambaDomainNames = array(); $sambaDomainNames = array();
for ($i = 0; $i < count($sambaDomains); $i++) { for ($i = 0; $i < count($sambaDomains); $i++) {
$sambaDomainNames[] = $sambaDomains[$i]->name; $sambaDomainNames[] = $sambaDomains[$i]->name;
@ -1159,7 +1159,7 @@ class sambaSamAccount extends baseModule {
// domain -> change SID // domain -> change SID
if ($this->attributes['sambaSID'][0]) { if ($this->attributes['sambaSID'][0]) {
if (isset($profile['sambaSamAccount_sambaDomainName'][0]) && ($profile['sambaSamAccount_sambaDomainName'][0] != "")) { if (isset($profile['sambaSamAccount_sambaDomainName'][0]) && ($profile['sambaSamAccount_sambaDomainName'][0] != "")) {
$domains = search_domains($_SESSION['config']->get_Suffix('domain')); $domains = search_domains();
$domSID = ''; $domSID = '';
// find domain SID // find domain SID
for ($i = 0; $i < sizeof($domains); $i++) { for ($i = 0; $i < sizeof($domains); $i++) {
@ -1208,7 +1208,7 @@ class sambaSamAccount extends baseModule {
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) {
$triggered_messages = array(); $triggered_messages = array();
// get list of Samba 3 domains // get list of Samba 3 domains
$domains = search_domains($_SESSION['config']->get_Suffix('domain')); $domains = search_domains();
// get list of Unix groups and their sambaSID + gidNumber // get list of Unix groups and their sambaSID + gidNumber
$groups = $_SESSION['cache']->get_cache(array('cn', 'sambaSID', 'gidNumber'), 'posixGroup', 'group'); $groups = $_SESSION['cache']->get_cache(array('cn', 'sambaSID', 'gidNumber'), 'posixGroup', 'group');
$groups_k = array_keys($groups); $groups_k = array_keys($groups);

View File

@ -301,6 +301,8 @@ function get_icon( $dn )
return 'nt_machine.png'; return 'nt_machine.png';
if( in_array( 'sambaaccount', $object_classes ) ) if( in_array( 'sambaaccount', $object_classes ) )
return 'nt_user.png'; return 'nt_user.png';
elseif( in_array( 'sambadomain', $object_classes ) )
return 'smbDomain.png';
elseif( in_array( 'person', $object_classes ) || elseif( in_array( 'person', $object_classes ) ||
in_array( 'organizationalperson', $object_classes ) || in_array( 'organizationalperson', $object_classes ) ||
in_array( 'inetorgperson', $object_classes ) || in_array( 'inetorgperson', $object_classes ) ||

124
lam/lib/types.inc Normal file
View File

@ -0,0 +1,124 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 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
*/
/**
* This file is the interface to the different account types.
*
* @package types
* @author Roland Gruber
*/
/** parent class of account types */
include_once("baseType.inc");
/** parent class of list views */
include_once("lists.inc");
/**
* This includes all type definitions.
*/
$typesINC_dirname = substr(__FILE__, 0, strlen(__FILE__) - 10) . "/types";
$typesINC_dir = dir($typesINC_dirname);
// get module names.
while ($entry = $typesINC_dir->read())
if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($typesINC_dirname . '/'.$entry)) {
include_once($typesINC_dirname . '/'.$entry);
}
/**
* Returns a list of available account types.
*
* @return array list of types
*/
function getTypes() {
$dirname = substr(__FILE__, 0, strlen(__FILE__) - 10) . "/types";
$dir = dir($dirname);
$return = array();
// get type names.
while ($entry = $dir->read())
if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($dirname . '/'.$entry)) {
$entry = substr($entry, 0, strpos($entry, '.'));
$return[] = $entry;
}
return $return;
}
/**
* Returns the alias name of an account type.
*
* @param string $type type name
* @return string type alias
*/
function getTypeAlias($type) {
$obj = new $type();
return $obj->getAlias();
}
/**
* Returns the description of an account type.
*
* @param string $type type name
* @return string type description
*/
function getTypeDescription($type) {
$obj = new $type();
return $obj->getDescription();
}
/**
* Returns the class name for the list object.
*
* @param string $type account type
* @return string class name
*/
function getListClassName($type) {
$obj = new $type();
return $obj->getListClassName();
}
/**
* Returns the default attribute list for an account type.
* It is used as default value for the configuration editor.
*
* @param string $type account type
* @return string attribute list
*/
function getDefaultListAttributes($type) {
$obj = new $type();
return $obj->getDefaultListAttributes();
}
/**
* Returns a list of attributes which have a translated description.
* This is used for the head row in the list view.
*
* @param string $type account type
* @return array list of descriptions
*/
function getListAttributeDescriptions($type) {
$obj = new $type();
return $obj->getListAttributeDescriptions();
}
?>

190
lam/lib/types/group.inc Normal file
View File

@ -0,0 +1,190 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 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
*/
/**
* The account type for group accounts (e.g. Unix and Samba).
*
* @package types
* @author Roland Gruber
*/
/**
* The account type for group accounts (e.g. Unix and Samba).
*/
class group extends baseType {
/**
* Returns the alias name of this account type.
*
* @return string alias name
*/
function getAlias() {
return _("Groups");
}
/**
* Returns the description of this account type.
*
* @return string description
*/
function getDescription() {
return _("Group accounts (e.g. Unix and Samba)");
}
/**
* Returns the class name for the list object.
*
* @return string class name
*/
function getListClassName() {
return "lamGroupList";
}
/**
* Returns the default attribute list for this account type.
*
* @return string attribute list
*/
function getDefaultListAttributes() {
return "#cn;#gidNumber;#memberUID;#description";
}
/**
* Returns a list of attributes which have a translated description.
* This is used for the head row in the list view.
*
* @return array list of descriptions
*/
function getListAttributeDescriptions() {
return array (
"cn" => _("Group name"),
"gidnumber" => _("GID number"),
"memberuid" => _("Group members"),
"member" => _("Group member DNs"),
"description" => _("Group description")
);
}
}
/**
* Generates the list view.
*
* @package lists
* @author Roland Gruber
*
*/
class lamGroupList extends lamList {
/**
* Constructor
*
* @param string $type account type
* @return lamList list object
*/
function lamGroupList($type) {
parent::lamList($type);
$this->labels = array(
'nav' => _("%s group(s) found"),
'error_noneFound' => _("No groups found!"),
'newEntry' => _("New group"),
'deleteEntry' => _("Delete group"),
'createPDF' => _("Create PDF for selected group(s)"),
'createPDFAll' => _("Create PDF for all groups"));
}
/**
* Prints the entry list
*
* @param array $info entries
*/
function listPrintTableBody($info) {
// calculate which rows to show
$table_begin = ($this->page - 1) * $this->maxPageEntries;
if (($this->page * $this->maxPageEntries) > sizeof($info)) $table_end = sizeof($info);
else $table_end = ($this->page * $this->maxPageEntries);
// print account list
for ($i = $table_begin; $i < $table_end; $i++) {
echo("<tr class=\"" . $this->type . "list\" onMouseOver=\"list_over(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" .
" onMouseOut=\"list_out(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" .
" onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" .
" onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=" . $this->type . "&amp;DN=" . $info[$i]['dn'] . "'\">\n");
if (isset($_GET['selectall'])) {
echo " <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"" .
" type=\"checkbox\" checked name=\"" . $info[$i]['LAM_ID'] . "\"></td>\n";
}
else {
echo " <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"" .
" type=\"checkbox\" name=\"" . $info[$i]['LAM_ID'] . "\"></td>\n";
}
echo (" <td align='center'><a href=\"../account/edit.php?type=" . $this->type . "&amp;DN='" . $info[$i]['dn'] . "'\">" . _("Edit") . "</a></td>\n");
for ($k = 0; $k < sizeof($this->attrArray); $k++) {
echo ("<td>");
// print all attribute entries seperated by "; "
$attrName = strtolower($this->attrArray[$k]);
if (isset($info[$i][$attrName]) && sizeof($info[$i][$attrName]) > 0) {
// delete "count" entry
unset($info[$i][$attrName]['count']);
// generate links for group members
if ($attrName == "memberuid") {
// sort array
sort($info[$i][$attrName]);
// make a link for each member of the group
$linklist = array();
for ($d = 0; $d < sizeof($info[$i][$attrName]); $d++) {
$user = $info[$i][$attrName][$d]; // user name
$linklist[$d] = "<a href=\"userlink.php?user='" . $user . "' \">" . $user . "</a>";
}
echo implode("; ", $linklist);
}
// print all other attributes
else {
if (is_array($info[$i][$attrName])) {
// sort array
sort($info[$i][$attrName]);
echo implode("; ", $info[$i][$attrName]);
}
else echo $info[$i][$attrName];
}
}
echo ("</td>\n");
}
echo("</tr>\n");
}
// display select all link
$colspan = sizeof($this->attrArray) + 1;
echo "<tr class=\"" . $this->type . "list\">\n";
echo "<td align=\"center\"><img src=\"../../graphics/select.png\" alt=\"select all\"></td>\n";
echo "<td colspan=$colspan>&nbsp;<a href=\"list.php?type=" . $this->type . "&amp;norefresh=y&amp;page=" . $this->page .
"&amp;sort=" . $this->sortColumn . $this->filterText . "&amp;selectall=yes\">" .
"<font color=\"black\"><b>" . _("Select all") . "</b></font></a></td>\n";
echo "</tr>\n";
echo ("</table>");
echo ("<br>");
}
}
?>

121
lam/lib/types/host.inc Normal file
View File

@ -0,0 +1,121 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 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
*/
/**
* The account type for host accounts (e.g. Samba).
*
* @package types
* @author Roland Gruber
*/
/**
* The account type for host accounts (e.g. Samba).
*/
class host extends baseType {
/**
* Returns the alias name of this account type.
*
* @return string alias name
*/
function getAlias() {
return _("Hosts");
}
/**
* Returns the description of this account type.
*
* @return string description
*/
function getDescription() {
return _("Host accounts (e.g. Samba)");
}
/**
* Returns the class name for the list object.
*
* @return string class name
*/
function getListClassName() {
return "lamHostList";
}
/**
* Returns the default attribute list for this account type.
*
* @return string attribute list
*/
function getDefaultListAttributes() {
return "#cn;#description;#uidNumber;#gidNumber";
}
/**
* Returns a list of attributes which have a translated description.
* This is used for the head row in the list view.
*
* @return array list of descriptions
*/
function getListAttributeDescriptions() {
return array (
"uid" => _("Host name"),
"cn" => _("Host name"),
"rid" => _("RID (Windows UID)"),
"description" => _("Host description"),
"uidnumber" => _("UID number"),
"gidnumber" => _("GID number")
);
}
}
/**
* Generates the list view.
*
* @package lists
* @author Roland Gruber
*
*/
class lamHostList extends lamList {
/**
* Constructor
*
* @param string $type account type
* @return lamList list object
*/
function lamHostList($type) {
parent::lamList($type);
$this->labels = array(
'nav' => _("%s host(s) found"),
'error_noneFound' => _("No hosts found!"),
'newEntry' => _("New host"),
'deleteEntry' => _("Delete host"),
'createPDF' => _("Create PDF for selected host(s)"),
'createPDFAll' => _("Create PDF for all hosts"));
}
}
?>

117
lam/lib/types/mailAlias.inc Normal file
View File

@ -0,0 +1,117 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 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
*/
/**
* The account type for mail aliases.
*
* @package types
* @author Roland Gruber
*/
/**
* The account type for mail aliases.
*/
class mailAlias extends baseType {
/**
* Returns the alias name of this account type.
*
* @return string alias name
*/
function getAlias() {
return _("Mail aliases");
}
/**
* Returns the description of this account type.
*
* @return string description
*/
function getDescription() {
return _("Mailing aliases (e.g. NIS mail aliases)");
}
/**
* Returns the class name for the list object.
*
* @return string class name
*/
function getListClassName() {
return "lamMailAliasList";
}
/**
* Returns the default attribute list for this account type.
*
* @return string attribute list
*/
function getDefaultListAttributes() {
return "#cn;#rfc822MailMember";
}
/**
* Returns a list of attributes which have a translated description.
* This is used for the head row in the list view.
*
* @return array list of descriptions
*/
function getListAttributeDescriptions() {
return array(
"cn" => _("Alias name"),
"rfc822MailMember" => _("Recipient list")
);
}
}
/**
* Generates the list view.
*
* @package lists
* @author Roland Gruber
*
*/
class lamMailAliasList extends lamList {
/**
* Constructor
*
* @param string $type account type
* @return lamList list object
*/
function lamMailAliasList($type) {
parent::lamList($type);
$this->labels = array(
'nav' => _("%s alias(es) found"),
'error_noneFound' => _("No aliases found!"),
'newEntry' => _("New alias"),
'deleteEntry' => _("Delete alias"),
'createPDF' => _("Create PDF for selected alias(es)"),
'createPDFAll' => _("Create PDF for all aliases"));
}
}
?>

116
lam/lib/types/smbDomain.inc Normal file
View File

@ -0,0 +1,116 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 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
*/
/**
* The account type for Samba domains.
*
* @package types
* @author Roland Gruber
*/
/**
* The account type for Samba domains.
*/
class smbDomain extends baseType {
/**
* Returns the alias name of this account type.
*
* @return string alias name
*/
function getAlias() {
return _("Samba domains");
}
/**
* Returns the description of this account type.
*
* @return string description
*/
function getDescription() {
return _("Samba 3 domain entries");
}
/**
* Returns the class name for the list object.
*
* @return string class name
*/
function getListClassName() {
return "lamSmbDomainList";
}
/**
* Returns the default attribute list for this account type.
*
* @return string attribute list
*/
function getDefaultListAttributes() {
return "#sambaDomainName;#sambaSID";
}
/**
* Returns a list of attributes which have a translated description.
* This is used for the head row in the list view.
*
* @return array list of descriptions
*/
function getListAttributeDescriptions() {
return array(
"sambaSID" => _("Domain SID"),
"sambaDomainName" => _("Domain name")
);
}
}
/**
* Generates the list view.
*
* @package lists
* @author Roland Gruber
*
*/
class lamSmbDomainList extends lamList {
/**
* Constructor
*
* @param string $type account type
* @return lamList list object
*/
function lamSmbDomainList($type) {
parent::lamList($type);
$this->labels = array(
'nav' => _("%s domain(s) found"),
'error_noneFound' => _("No domains found!"),
'newEntry' => _("New domain"),
'deleteEntry' => _("Delete domain"),
'createPDF' => _("Create PDF for selected domain(s)"),
'createPDFAll' => _("Create PDF for all domains"));
}
}
?>

247
lam/lib/types/user.inc Normal file
View File

@ -0,0 +1,247 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 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
*/
/**
* The account type for user accounts (e.g. Unix, Samba and Kolab).
*
* @package types
* @author Roland Gruber
*/
/**
* The account type for user accounts (e.g. Unix, Samba and Kolab).
*/
class user extends baseType {
/**
* Returns the alias name of this account type.
*
* @return string alias name
*/
function getAlias() {
return _("Users");
}
/**
* Returns the description of this account type.
*
* @return string description
*/
function getDescription() {
return _("User accounts (e.g. Unix, Samba and Kolab)");
}
/**
* Returns the class name for the list object.
*
* @return string class name
*/
function getListClassName() {
return "lamUserList";
}
/**
* Returns the default attribute list for this account type.
*
* @return string attribute list
*/
function getDefaultListAttributes() {
return "#uid;#givenName;#sn;#uidNumber;#gidNumber";
}
/**
* Returns a list of attributes which have a translated description.
* This is used for the head row in the list view.
*
* @return array list of descriptions
*/
function getListAttributeDescriptions() {
return array (
"uid" => _("User ID"),
"uidnumber" => _("UID number"),
"gidnumber" => _("GID number"),
"cn" => _("User name"),
"host" => _("Allowed hosts"),
"givenname" => _("First name"),
"sn" => _("Last name"),
"homedirectory" => _("Home directory"),
"loginshell" => _("Login shell"),
"mail" => _("E-Mail"),
"gecos" => _("Description")
);
}
}
/**
* Generates the list view.
*
* @package lists
* @author Roland Gruber
*
*/
class lamUserList extends lamList {
/** Controls if GID number is translated to group name */
var $trans_primary = false;
/** translates GID to group name */
var $trans_primary_hash = array();
/**
* Constructor
*
* @param string $type account type
* @return lamList list object
*/
function lamUserList($type) {
parent::lamList($type);
$this->labels = array(
'nav' => _("%s user(s) found"),
'error_noneFound' => _("No users found!"),
'newEntry' => _("New user"),
'deleteEntry' => _("Delete user"),
'createPDF' => _("Create PDF for selected user(s)"),
'createPDFAll' => _("Create PDF for all users"));
}
/**
* Manages all POST actions (e.g. button pressed) for the account lists.
*/
function listDoPost() {
parent::listDoPost();
// check if primary group should be translated
if (isset($_POST['apply_trans_primary'])) {
$this->trans_primary = $_POST['trans_primary'];
}
// generate hash table for group translation
if ($this->trans_primary == "on" && ($this->refresh || (sizeof($this->trans_primary_hash) == 0))) {
$this->trans_primary_hash = array();
$grp_suffix = $_SESSION['config']->get_Suffix('group');
$filter = "objectClass=posixGroup";
$attrs = array("cn", "gidNumber");
$sr = @ldap_search($_SESSION["ldap"]->server(), $grp_suffix, $filter, $attrs);
if ($sr) {
$info = @ldap_get_entries($_SESSION["ldap"]->server(), $sr);
unset($info['count']); // delete count entry
for ($i = 0; $i < sizeof($info); $i++) {
$this->trans_primary_hash[$info[$i]['gidnumber'][0]] = $info[$i]['cn'][0];
}
}
}
}
/**
* Prints the entry list
*
* @param array $info entries
*/
function listPrintTableBody($info) {
// calculate which rows to show
$table_begin = ($this->page - 1) * $this->maxPageEntries;
if (($this->page * $this->maxPageEntries) > sizeof($info)) $table_end = sizeof($info);
else $table_end = ($this->page * $this->maxPageEntries);
// translate GIDs and resort array if selected
if ($this->trans_primary == "on") {
// translate GIDs
for ($i = 0; $i < sizeof($info); $i++) {
if (isset($this->trans_primary_hash[$info[$i]['gidnumber'][0]])) {
$info[$i]['gidnumber'][0] = $this->trans_primary_hash[$info[$i]['gidnumber'][0]];
}
}
// resort if needed
if ($this->sortColumn == "gidnumber") {
$info = $this->listSort($info);
}
}
// print account list
for ($i = $table_begin; $i < $table_end; $i++) {
echo("<tr class=\"" . $this->type . "list\" onMouseOver=\"list_over(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" .
" onMouseOut=\"list_out(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" .
" onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"\n" .
" onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=" . $this->type . "&amp;DN=" . $info[$i]['dn'] . "'\">\n");
if (isset($_GET['selectall'])) {
echo " <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"" .
" type=\"checkbox\" checked name=\"" . $info[$i]['LAM_ID'] . "\"></td>\n";
}
else {
echo " <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $this->type . "')\"" .
" type=\"checkbox\" name=\"" . $info[$i]['LAM_ID'] . "\"></td>\n";
}
echo (" <td align='center'><a href=\"../account/edit.php?type=" . $this->type . "&amp;DN='" . $info[$i]['dn'] . "'\">" . _("Edit") . "</a></td>\n");
for ($k = 0; $k < sizeof($this->attrArray); $k++) {
echo ("<td>");
// print all attribute entries seperated by "; "
$attrName = strtolower($this->attrArray[$k]);
if (isset($info[$i][$attrName]) && sizeof($info[$i][$attrName]) > 0) {
// delete "count" entry
unset($info[$i][$attrName]['count']);
if (is_array($info[$i][$attrName])) {
// sort array
sort($info[$i][$attrName]);
echo implode("; ", $info[$i][$attrName]);
}
else echo $info[$i][$attrName];
}
echo ("</td>\n");
}
echo("</tr>\n");
}
// display select all link
$colspan = sizeof($this->attrArray) + 1;
echo "<tr class=\"" . $this->type . "list\">\n";
echo "<td align=\"center\"><img src=\"../../graphics/select.png\" alt=\"select all\"></td>\n";
echo "<td colspan=$colspan>&nbsp;<a href=\"list.php?type=" . $this->type . "&amp;norefresh=y&amp;page=" . $this->page .
"&amp;sort=" . $this->sortColumn . $this->filterText . "&amp;selectall=yes\">" .
"<font color=\"black\"><b>" . _("Select all") . "</b></font></a></td>\n";
echo "</tr>\n";
echo ("</table>");
echo ("<br>");
}
/**
* Prints the create, delete and PDF buttons.
*
* @param boolean $createOnly true if only the create button should be displayed
*/
function listPrintButtons($createOnly) {
// show translate GID to group name box if there is a column with gidnumber
if (in_array("gidnumber", $this->attrArray)) {
echo "<p align=\"left\">\n";
echo "<b>" . _("Translate GID number to group name") . ": </b>";
if ($this->trans_primary == "on") {
echo "<input type=\"checkbox\" name=\"trans_primary\" checked>";
}
else echo "<input type=\"checkbox\" name=\"trans_primary\">";
echo ("&nbsp;&nbsp;<input type=\"submit\" name=\"apply_trans_primary\" value=\"" . _("Apply") . "\">");
echo "</p>\n";
}
echo ("<p>&nbsp;</p>\n");
parent::listPrintButtons($createOnly);
}
}
?>

View File

@ -79,253 +79,8 @@ legend {
color:#007a3b; color:#007a3b;
} }
fieldset fieldset legend {
/** color:black;
* style for userlist.php
*
*/
/* table preferences */
table.userlist {
border-width:1px;
border-style:solid;
border-color:#9b8523;
}
/* color of entry rows */
tr.userlist {
background-color:#fffde2;
}
/* color of head row */
tr.userlist-head {
background-color:#fff2a3;
font-weight:bold;
}
/* color of rows on mouseOver */
tr.userlist-over {
background-color:#ccccff;
}
/* color of checked rows */
tr.userlist-checked {
background-color:#f27c71;
}
/* color for active page digit */
td.usernav-activepage {
color:red;
}
/* style of navigation bar */
td.usernav {
color:#AAAAAA;
}
table.usernav {
background-color:#fff2a3;
border-width:1px;
border-style:solid;
border-color:#9b8523;
}
td.usernav-text {
color:green;
font-family:Verdana,sans-serif;
font-size:12px;
}
/* style of active column */
th.userlist-sort {
background-color:#fffde2;
}
/**
* table style for grouplist.php
*
*/
/* navigation bar */
table.groupnav {
background-color:#a8c3ff;
border-width:1px;
border-style:solid;
border-color:#7167bf;
}
/* text in navigation bar */
td.groupnav-text {
color:green;
font-family:Verdana,sans-serif;
font-size:12px;
}
/* color for active page digit */
td.groupnav-activepage {
color:red;
}
/* table preferences */
table.grouplist {
border-width:1px;
border-style:solid;
border-color:#7167bf;
}
/* color of entry rows */
tr.grouplist {
background-color:#d6e3ff;
}
/* color of head row */
tr.grouplist-head {
background-color:#a8c3ff;
}
/* color of sorted column in head row */
th.grouplist-sort {
background-color:#d6e3ff;
}
/* color of rows on mouseOver */
tr.grouplist-over {
background-color:#C7E7C7;
}
/* color of checked rows */
tr.grouplist-checked {
background-color:#f27c71;
}
/**
* table style for hostlist.php
*
*/
/* */
table.hostnav {
background-color:#ffc4ba;
border-width:1px;
border-style:solid;
border-color:#911a1a;
}
/* text in navigation bar */
td.hostnav-text {
color:green;
font-family:Verdana,sans-serif;
font-size:12px;
}
/* color for active page digit */
td.hostnav-activepage {
color:red;
}
/* table preferences */
table.hostlist {
border-width:1px;
border-style:solid;
border-color:#911a1a;
}
/* color of entry rows */
tr.hostlist {
background-color:#ffe2dd;
}
/* color of head row */
tr.hostlist-head {
background-color:#ffc4ba;
}
/* color of sorted column in head row */
th.hostlist-sort {
background-color:#ffe2dd;
}
/* color of rows on mouseOver */
tr.hostlist-over {
background-color:#ffe265;
}
/* color of checked rows */
tr.hostlist-checked {
background-color:#f27c71;
}
/**
* table style for domainlist.php
*
*/
/* */
table.domainnav {
background-color:#a8ddbf;
border-width:1px;
border-style:solid;
border-color:#1d993e;
}
/* text in navigation bar */
td.domainnav-text {
color:green;
font-family:Verdana,sans-serif;
font-size:12px;
}
/* color for active page digit */
td.domainnav-activepage {
color:red;
}
/* table preferences */
table.domainlist {
border-width:1px;
border-style:solid;
border-color:#1d993e;
}
/* color of entry rows */
tr.domainlist {
background-color:#c9ddd2;
}
/* color of head row */
tr.domainlist-head {
background-color:#a8ddbf;
}
/* color of sorted column in head row */
th.domainlist-sort {
background-color:#c9ddd2;
}
/* color of rows on mouseOver */
tr.domainlist-over {
background-color:#ffe265;
}
/* color of checked rows */
tr.domainlist-checked {
background-color:#f27c71;
}
/**
* style for domain.php
*
*/
/* fieldset and legend */
fieldset.domedit {
background-color:#c9ddd2;
}
legend.domedit {
color:blue;
} }
@ -437,83 +192,6 @@ p.statusError {
margin-right:35px; margin-right:35px;
} }
/**
* table style for groupedit.php
*
*/
fieldset.groupedit {
background-color:#d6e3ff;
}
fieldset.groupedit legend {
color:blue;
}
fieldset.groupedit fieldset {
background-color:#d6e3ff;
}
fieldset.groupedit fieldset fieldset {
background-color:#d6e3ff;
}
fieldset.groupedit select {
background-color:#a8c3ff;
}
/**
* table style for hostedit.php
*
*/
fieldset.hostedit {
background-color:#ffe2dd;
}
fieldset.hostedit legend {
color:blue;
}
fieldset.hostedit fieldset {
background-color:#ffe2dd;
}
fieldset.hostedit fieldset fieldset {
background-color:#ffe2dd;
}
fieldset.hostedit select {
background-color:#ffc4ba;
}
/**
* table style for useredit.php
*
*/
fieldset.useredit {
background-color:#fff2a3;
}
fieldset.useredit legend {
color:blue;
}
fieldset.useredit fieldset {
background-color:#fff2a3;
}
fieldset.useredit fieldset fieldset {
background-color:#fff2a3;
}
fieldset.useredit select {
background-color:#fffde2;
}
/* schema browser */ /* schema browser */

View File

@ -0,0 +1,100 @@
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2005-2006 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 detaexils.
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
*/
/**
* style definition for group accounts
*/
/* navigation bar */
table.groupnav {
background-color:#a8c3ff;
border-width:1px;
border-style:solid;
border-color:#7167bf;
}
/* text in navigation bar */
td.groupnav-text {
color:green;
font-family:Verdana,sans-serif;
font-size:12px;
}
/* color for active page digit */
td.groupnav-activepage {
color:red;
}
/* table preferences */
table.grouplist {
border-width:1px;
border-style:solid;
border-color:#7167bf;
}
/* color of entry rows */
tr.grouplist {
background-color:#d6e3ff;
}
/* color of head row */
tr.grouplist-head {
background-color:#a8c3ff;
}
/* color of sorted column in head row */
th.grouplist-sort {
background-color:#d6e3ff;
}
/* color of rows on mouseOver */
tr.grouplist-over {
background-color:#C7E7C7;
}
/* color of checked rows */
tr.grouplist-checked {
background-color:#f27c71;
}
fieldset.groupedit {
background-color:#d6e3ff;
}
fieldset.groupedit legend {
color:blue;
}
fieldset.groupedit fieldset {
background-color:#d6e3ff;
}
fieldset.groupedit fieldset fieldset {
background-color:#d6e3ff;
}
fieldset.groupedit select {
background-color:#a8c3ff;
}

100
lam/style/600_type_host.css Normal file
View File

@ -0,0 +1,100 @@
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2005-2006 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 detaexils.
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
*/
/**
* style definition for host accounts
*
*/
/* */
table.hostnav {
background-color:#ffc4ba;
border-width:1px;
border-style:solid;
border-color:#911a1a;
}
/* text in navigation bar */
td.hostnav-text {
color:green;
font-family:Verdana,sans-serif;
font-size:12px;
}
/* color for active page digit */
td.hostnav-activepage {
color:red;
}
/* table preferences */
table.hostlist {
border-width:1px;
border-style:solid;
border-color:#911a1a;
}
/* color of entry rows */
tr.hostlist {
background-color:#ffe2dd;
}
/* color of head row */
tr.hostlist-head {
background-color:#ffc4ba;
}
/* color of sorted column in head row */
th.hostlist-sort {
background-color:#ffe2dd;
}
/* color of rows on mouseOver */
tr.hostlist-over {
background-color:#ffe265;
}
/* color of checked rows */
tr.hostlist-checked {
background-color:#f27c71;
}
fieldset.hostedit {
background-color:#ffe2dd;
}
fieldset.hostedit legend {
color:blue;
}
fieldset.hostedit fieldset {
background-color:#ffe2dd;
}
fieldset.hostedit fieldset fieldset {
background-color:#ffe2dd;
}
fieldset.hostedit select {
background-color:#ffc4ba;
}

View File

@ -0,0 +1,100 @@
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2005-2006 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 detaexils.
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
*/
/**
* style definition for mailing list accounts
*/
/* navigation bar */
table.mailAliasnav {
background-color:#ffe27f;
border-width:1px;
border-style:solid;
border-color:#af8800;
}
/* text in navigation bar */
td.mailAliasnav-text {
color:green;
font-family:Verdana,sans-serif;
font-size:12px;
}
/* color for active page digit */
td.mailAliasnav-activepage {
color:red;
}
/* table preferences */
table.mailAliaslist {
border-width:1px;
border-style:solid;
border-color:#af8800;
}
/* color of entry rows */
tr.mailAliaslist {
background-color:#fff3c8;
}
/* color of head row */
tr.mailAliaslist-head {
background-color:#ffe27f;
}
/* color of sorted column in head row */
th.mailAliaslist-sort {
background-color:#fff3c8;
}
/* color of rows on mouseOver */
tr.mailAliaslist-over {
background-color:#d6e3ff;
}
/* color of checked rows */
tr.mailAliaslist-checked {
background-color:#f27c71;
}
fieldset.mailAliasedit {
background-color:#fff3c8;
}
fieldset.mailAliasedit legend {
color:blue;
}
fieldset.mailAliasedit fieldset {
background-color:#fff3c8;
}
fieldset.mailAliasedit fieldset fieldset {
background-color:#fff3c8;
}
fieldset.mailAliasedit select {
background-color:#ffe27f;
}

View File

@ -0,0 +1,100 @@
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2005-2006 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 detaexils.
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
*/
/**
* style definition for smbDomain accounts
*
*/
/* */
table.smbDomainnav {
background-color:#a8ddbf;
border-width:1px;
border-style:solid;
border-color:#1d993e;
}
/* text in navigation bar */
td.smbDomainnav-text {
color:green;
font-family:Verdana,sans-serif;
font-size:12px;
}
/* color for active page digit */
td.smbDomainnav-activepage {
color:red;
}
/* table preferences */
table.smbDomainlist {
border-width:1px;
border-style:solid;
border-color:#1d993e;
}
/* color of entry rows */
tr.smbDomainlist {
background-color:#c9ddd2;
}
/* color of head row */
tr.smbDomainlist-head {
background-color:#a8ddbf;
}
/* color of sorted column in head row */
th.smbDomainlist-sort {
background-color:#c9ddd2;
}
/* color of rows on mouseOver */
tr.smbDomainlist-over {
background-color:#ffe265;
}
/* color of checked rows */
tr.smbDomainlist-checked {
background-color:#f27c71;
}
fieldset.smbDomainedit {
background-color:#c9ddd2;
}
fieldset.smbDomainedit legend {
color:blue;
}
fieldset.smbDomainedit fieldset {
background-color:#c9ddd2;
}
fieldset.smbDomainedit fieldset fieldset {
background-color:#c9ddd2;
}
fieldset.smbDomainedit select {
background-color:#a8ddbf;
}

119
lam/style/600_type_user.css Normal file
View File

@ -0,0 +1,119 @@
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2005-2006 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 detaexils.
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
*/
/**
* style definition for user accounts
*/
/**
* Preferences for the list view and some other pages which have no own definitions (e.g. profile editor).
*/
/* main table of account list */
table.userlist {
border-width:1px;
border-style:solid;
border-color:#9b8523;
}
/* color of entry rows */
tr.userlist {
background-color:#fffde2;
}
/* color of head row */
tr.userlist-head {
background-color:#fff2a3;
font-weight:bold;
}
/* color of rows on mouseOver */
tr.userlist-over {
background-color:#ccccff;
}
/* color of checked rows */
tr.userlist-checked {
background-color:#f27c71;
}
/* color of sorted column */
th.userlist-sort {
background-color:#fffde2;
}
/* style of navigation bar */
table.usernav {
background-color:#fff2a3;
border-width:1px;
border-style:solid;
border-color:#9b8523;
}
/* text area in the center, e.g. "100 object(s) found" */
td.usernav-text {
color:green;
font-family:Verdana,sans-serif;
font-size:12px;
}
/* color for active page number */
td.usernav-activepage {
color:red;
}
/* account pages */
/* main fieldset */
fieldset.useredit {
background-color:#fff2a3;
}
/* legend of main fieldset */
fieldset.useredit legend {
color:blue;
}
/* subfieldset */
fieldset.useredit fieldset {
background-color:#fff2a3;
}
/* subsubfieldset */
fieldset.useredit fieldset fieldset {
background-color:#fff2a3;
}
/* select boxes */
fieldset.useredit select {
background-color:#fffde2;
}

View File

@ -42,22 +42,10 @@ session_save_path("../../sess");
setlanguage(); setlanguage();
// remove settings from session // remove settings from session
unset($_SESSION['conf_passwd']); $sessionKeys = array_keys($_SESSION);
unset($_SESSION['conf_passwd1']); for ($i = 0; $i < sizeof($sessionKeys); $i++) {
unset($_SESSION['conf_passwd2']); if (substr($sessionKeys[$i], 0, 5) == "conf_") unset($_SESSION[$sessionKeys[$i]]);
unset($_SESSION['conf_serverurl']); }
unset($_SESSION['conf_admins']);
unset($_SESSION['conf_suffusers']);
unset($_SESSION['conf_suffgroups']);
unset($_SESSION['conf_suffhosts']);
unset($_SESSION['conf_usrlstattr']);
unset($_SESSION['conf_grplstattr']);
unset($_SESSION['conf_hstlstattr']);
unset($_SESSION['conf_maxlistentries']);
unset($_SESSION['conf_lang']);
unset($_SESSION['conf_scriptpath']);
unset($_SESSION['conf_scriptserver']);
unset($_SESSION['conf_filename']);
echo $_SESSION['header']; echo $_SESSION['header'];

View File

@ -43,9 +43,9 @@ session_save_path("../../sess");
setlanguage(); setlanguage();
// check if button was pressed and if we have to save the setting or go back to login // check if button was pressed and if we have to save the setting or go back to login
if (isset($_POST['back']) || isset($_POST['submitconf']) || isset($_POST['editmodules'])){ if (isset($_POST['back']) || isset($_POST['submitconf']) || isset($_POST['editmodules']) || isset($_POST['edittypes'])){
// save settings // save settings
if ($_POST['submitconf'] || $_POST['editmodules']){ if ($_POST['submitconf'] || $_POST['editmodules'] || $_POST['edittypes']){
// save HTTP-POST variables in session // save HTTP-POST variables in session
$_SESSION['conf_passwd'] = $_POST['passwd']; $_SESSION['conf_passwd'] = $_POST['passwd'];
$_SESSION['conf_passwd1'] = $_POST['passwd1']; $_SESSION['conf_passwd1'] = $_POST['passwd1'];
@ -53,21 +53,11 @@ if (isset($_POST['back']) || isset($_POST['submitconf']) || isset($_POST['editmo
$_SESSION['conf_serverurl'] = $_POST['serverurl']; $_SESSION['conf_serverurl'] = $_POST['serverurl'];
$_SESSION['conf_cachetimeout'] = $_POST['cachetimeout']; $_SESSION['conf_cachetimeout'] = $_POST['cachetimeout'];
$_SESSION['conf_admins'] = $_POST['admins']; $_SESSION['conf_admins'] = $_POST['admins'];
$_SESSION['conf_suffusers'] = $_POST['suffusers'];
$_SESSION['conf_suffgroups'] = $_POST['suffgroups'];
$_SESSION['conf_suffhosts'] = $_POST['suffhosts'];
$_SESSION['conf_suffdomains'] = $_POST['suffdomains'];
$_SESSION['conf_sufftree'] = $_POST['sufftree']; $_SESSION['conf_sufftree'] = $_POST['sufftree'];
$_SESSION['conf_usrlstattr'] = $_POST['usrlstattr'];
$_SESSION['conf_grplstattr'] = $_POST['grplstattr'];
$_SESSION['conf_hstlstattr'] = $_POST['hstlstattr'];
$_SESSION['conf_maxlistentries'] = $_POST['maxlistentries']; $_SESSION['conf_maxlistentries'] = $_POST['maxlistentries'];
$_SESSION['conf_lang'] = $_POST['lang']; $_SESSION['conf_lang'] = $_POST['lang'];
$_SESSION['conf_scriptpath'] = $_POST['scriptpath']; $_SESSION['conf_scriptpath'] = $_POST['scriptpath'];
$_SESSION['conf_scriptserver'] = $_POST['scriptserver']; $_SESSION['conf_scriptserver'] = $_POST['scriptserver'];
$_SESSION['conf_usermodules'] = explode(",", $_POST['usermodules']);
$_SESSION['conf_groupmodules'] = explode(",", $_POST['groupmodules']);
$_SESSION['conf_hostmodules'] = explode(",", $_POST['hostmodules']);
$_SESSION['conf_filename'] = $_POST['filename']; $_SESSION['conf_filename'] = $_POST['filename'];
$modSettings = array_keys($_SESSION['config_types']); $modSettings = array_keys($_SESSION['config_types']);
for ($i = 0; $i < sizeof($modSettings); $i++) $_SESSION['config_moduleSettings'][$modSettings[$i]] = $_POST[$modSettings[$i]]; for ($i = 0; $i < sizeof($modSettings); $i++) $_SESSION['config_moduleSettings'][$modSettings[$i]] = $_POST[$modSettings[$i]];
@ -80,6 +70,10 @@ if (isset($_POST['back']) || isset($_POST['submitconf']) || isset($_POST['editmo
elseif ($_POST['editmodules']){ elseif ($_POST['editmodules']){
metaRefresh("confmodules.php"); metaRefresh("confmodules.php");
} }
// go to types page
elseif ($_POST['edittypes']){
metaRefresh("conftypes.php");
}
// back to login // back to login
else if ($_POST['back']){ else if ($_POST['back']){
metaRefresh("../login.php"); metaRefresh("../login.php");
@ -89,7 +83,7 @@ if (isset($_POST['back']) || isset($_POST['submitconf']) || isset($_POST['editmo
// get password if register_globals is off // get password if register_globals is off
if (isset($_POST['passwd'])) $passwd = $_POST['passwd']; if (isset($_POST['passwd'])) $passwd = $_POST['passwd'];
if (isset($_GET["modulesback"])) $passwd = $_SESSION['conf_passwd']; if (isset($_GET["modulesback"]) || isset($_GET["typesback"])) $passwd = $_SESSION['conf_passwd'];
// check if password was entered // check if password was entered
// if not: load login page // if not: load login page
@ -101,7 +95,7 @@ if (! $passwd) {
} }
$filename = $_POST['filename']; $filename = $_POST['filename'];
if (isset($_GET["modulesback"])) $filename = $_SESSION['conf_filename']; if (isset($_GET["modulesback"]) || isset($_GET["typesback"])) $filename = $_SESSION['conf_filename'];
$conf = new Config($filename); $conf = new Config($filename);
// check if password is valid // check if password is valid
@ -119,26 +113,26 @@ if (isset($_GET["modulesback"])) {
$conf->set_ServerURL($_SESSION['conf_serverurl']); $conf->set_ServerURL($_SESSION['conf_serverurl']);
$conf->set_cacheTimeout($_SESSION['conf_cachetimeout']); $conf->set_cacheTimeout($_SESSION['conf_cachetimeout']);
$conf->set_Adminstring($_SESSION['conf_admins']); $conf->set_Adminstring($_SESSION['conf_admins']);
$conf->set_Suffix('user', $_SESSION['conf_suffusers']);
$conf->set_Suffix('group', $_SESSION['conf_suffgroups']);
$conf->set_Suffix('host', $_SESSION['conf_suffhosts']);
$conf->set_Suffix('domain', $_SESSION['conf_suffdomains']);
$conf->set_Suffix('tree', $_SESSION['conf_sufftree']); $conf->set_Suffix('tree', $_SESSION['conf_sufftree']);
$conf->set_listAttributes($_SESSION['conf_usrlstattr'], 'user');
$conf->set_listAttributes($_SESSION['conf_grplstattr'], 'group');
$conf->set_listAttributes($_SESSION['conf_hstlstattr'], 'host');
$conf->set_MaxListEntries($_SESSION['conf_maxlistentries']); $conf->set_MaxListEntries($_SESSION['conf_maxlistentries']);
$conf->set_defaultLanguage($_SESSION['conf_lang']); $conf->set_defaultLanguage($_SESSION['conf_lang']);
$conf->set_scriptpath($_SESSION['conf_scriptpath']); $conf->set_scriptpath($_SESSION['conf_scriptpath']);
$conf->set_scriptserver($_SESSION['conf_scriptserver']); $conf->set_scriptserver($_SESSION['conf_scriptserver']);
// check if modules were edited }
if ($_GET["moduleschanged"] == "true") {
$conf->set_AccountModules($_SESSION['conf_usermodules'], 'user'); // check if user comes from types page
$conf->set_AccountModules($_SESSION['conf_groupmodules'], 'group'); if (isset($_GET["typesback"])) {
$conf->set_AccountModules($_SESSION['conf_hostmodules'], 'host'); // check if a new account type was added
if (isset($_GET["typeschanged"])) {
metaRefresh("confmodules.php");
exit;
} }
} }
// type information
if (!isset($_SESSION['conf_accountTypes'])) $_SESSION['conf_accountTypes'] = $conf->get_ActiveTypes();
if (!isset($_SESSION['conf_typeSettings'])) $_SESSION['conf_typeSettings'] = $conf->get_typeSettings();
// index for tab order // index for tab order
$tabindex = 1; $tabindex = 1;
$tabindexLink = 1000; $tabindexLink = 1000;
@ -172,49 +166,9 @@ $tabindex++;
// new line // new line
echo ("<tr><td colspan=3>&nbsp</td></tr>"); echo ("<tr><td colspan=3>&nbsp</td></tr>");
// user suffix
echo ("<tr><td align=\"right\"><b>".
_("UserSuffix") . ": </b></td>".
"<td><input tabindex=\"$tabindex\" size=50 type=\"text\" name=\"suffusers\" value=\"" . $conf->get_Suffix('user') . "\"></td>\n");
echo "<td>";
echo "<a href=\"../help.php?HelpNumber=202\" target=\"lamhelp\">";
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
echo "</a>\n";
echo "</td></tr>\n";
$tabindex++;
// group suffix
echo ("<tr><td align=\"right\"><b>".
_("GroupSuffix") . ": </b></td>".
"<td><input tabindex=\"$tabindex\" size=50 type=\"text\" name=\"suffgroups\" value=\"" . $conf->get_Suffix('group') . "\"></td>\n");
echo "<td>";
echo "<a href=\"../help.php?HelpNumber=202\" target=\"lamhelp\">";
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
echo "</a>\n";
echo "</td></tr>\n";
$tabindex++;
// host suffix
echo ("<tr><td align=\"right\"><b>".
_("HostSuffix") . ": </b></td>".
"<td><input tabindex=\"$tabindex\" size=50 type=\"text\" name=\"suffhosts\" value=\"" . $conf->get_Suffix('host') . "\"></td>\n");
echo "<td>";
echo "<a href=\"../help.php?HelpNumber=202\" target=\"lamhelp\">";
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
echo "</a>\n";
echo "</td></tr>\n";
$tabindex++;
// domain suffix
echo ("<tr><td align=\"right\"><b>".
_("DomainSuffix") . " **: </b></td>".
"<td><input tabindex=\"$tabindex\" size=50 type=\"text\" name=\"suffdomains\" value=\"" . $conf->get_Suffix('domain') . "\"></td>\n");
echo "<td>";
echo "<a href=\"../help.php?HelpNumber=202\" target=\"lamhelp\">";
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
echo "</a>\n";
echo "</td></tr>\n";
$tabindex++;
// tree suffix // tree suffix
echo ("<tr><td align=\"right\"><b>". echo ("<tr><td align=\"right\"><b>".
_("TreeSuffix") . ": </b></td>". _("Tree suffix") . ": </b></td>".
"<td><input tabindex=\"$tabindex\" size=50 type=\"text\" name=\"sufftree\" value=\"" . $conf->get_Suffix('tree') . "\"></td>\n"); "<td><input tabindex=\"$tabindex\" size=50 type=\"text\" name=\"sufftree\" value=\"" . $conf->get_Suffix('tree') . "\"></td>\n");
echo "<td>"; echo "<td>";
echo "<a href=\"../help.php?HelpNumber=203\" target=\"lamhelp\">"; echo "<a href=\"../help.php?HelpNumber=203\" target=\"lamhelp\">";
@ -249,22 +203,22 @@ echo ("</fieldset>");
echo ("<p></p>"); echo ("<p></p>");
echo ("<fieldset><legend><b>" . _("Account modules") . "</b></legend>"); echo ("<fieldset><legend><b>" . _("Account types and modules") . "</b></legend>");
echo ("<table border=0>");
// Account modules // Account modules
echo "<tr><td><b>" . _("User modules") . ": </b>" . implode(", ", $conf->get_AccountModules('user')) . "</td></tr>\n"; $types = $_SESSION['conf_accountTypes'];
echo "<tr><td><b>" . _("Group modules") . ": </b>" . implode(", ", $conf->get_AccountModules('group')) . "</td></tr>\n"; for ($i = 0; $i < sizeof($types); $i++) {
echo "<tr><td><b>" . _("Host modules") . ": </b>" . implode(", ", $conf->get_AccountModules('host')) . "</td></tr>\n"; echo "<b>" . getTypeAlias($types[$i]) . ": </b>" . implode(", ", $conf->get_AccountModules($types[$i])) . "<br>\n";
echo "<tr><td>&nbsp;</td></tr>\n"; }
echo "<tr><td><input tabindex=\"$tabindex\" type=\"submit\" name=\"editmodules\" value=\"" . _("Edit modules") . "\">&nbsp;&nbsp;"; echo "<br>\n";
echo "<input tabindex=\"$tabindex\" type=\"submit\" name=\"edittypes\" value=\"" . _("Edit account types") . "\">&nbsp;&nbsp;";
$tabindex++;
echo "<input tabindex=\"$tabindex\" type=\"submit\" name=\"editmodules\" value=\"" . _("Edit modules") . "\">&nbsp;&nbsp;";
echo "<a href=\"../help.php?HelpNumber=217\" target=\"lamhelp\">"; echo "<a href=\"../help.php?HelpNumber=217\" target=\"lamhelp\">";
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">"; echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
echo "</a>\n"; echo "</a>\n";
echo "</td></tr>\n";
$tabindex++; $tabindex++;
echo ("</table>");
echo ("</fieldset>"); echo ("</fieldset>");
echo ("<p></p>"); echo ("<p></p>");
@ -274,12 +228,10 @@ echo ("<p></p>");
// get list of scopes of modules // get list of scopes of modules
$scopes = array(); $scopes = array();
$mods = $conf->get_AccountModules('user'); for ($m = 0; $m < sizeof($types); $m++) {
for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = 'user'; $mods = $conf->get_AccountModules($types[$m]);
$mods = $conf->get_AccountModules('group'); for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = $types[$m];
for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = 'group'; }
$mods = $conf->get_AccountModules('host');
for ($i = 0; $i < sizeof($mods); $i++) $scopes[$mods[$i]][] = 'host';
// get module options // get module options
$options = getConfigOptions($scopes); $options = getConfigOptions($scopes);
@ -305,42 +257,9 @@ for ($i = 0; $i < sizeof($modules); $i++) {
} }
echo ("<fieldset><legend><b>" . _("LDAP List settings") . "</b></legend>\n"); echo ("<fieldset><legend><b>" . _("List settings") . "</b></legend>\n");
echo ("<table border=0>\n"); echo ("<table border=0>\n");
// user list attributes
echo ("<tr><td align=\"right\"><b>".
_("Attributes in User List") . " *:</b></td>".
"<td><input tabindex=\"$tabindex\" size=50 type=\"text\" name=\"usrlstattr\" value=\"" . $conf->get_listAttributes('user') . "\"></td>");
echo "<td>";
echo "<a href=\"../help.php?HelpNumber=206\" target=\"lamhelp\">";
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
echo "</a>\n";
echo "</td></tr>\n";
$tabindex++;
// group list attributes
echo ("<tr><td align=\"right\"><b>".
_("Attributes in Group List") . " *:</b></td>".
"<td><input tabindex=\"$tabindex\" size=50 type=\"text\" name=\"grplstattr\" value=\"" . $conf->get_listAttributes('group') . "\"></td>");
echo "<td>";
echo "<a href=\"../help.php?HelpNumber=206\" target=\"lamhelp\">";
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
echo "</a>\n";
echo "</td></tr>\n";
$tabindex++;
// host list attributes
echo ("<tr><td align=\"right\"><b>".
_("Attributes in Host List") . " **:</b></td>".
"<td><input tabindex=\"$tabindex\" size=50 type=\"text\" name=\"hstlstattr\" value=\"" . $conf->get_listAttributes('host') . "\"></td>");
echo "<td>";
echo "<a href=\"../help.php?HelpNumber=206\" target=\"lamhelp\">";
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
echo "</a>\n";
echo "</td></tr>\n";
$tabindex++;
echo ("<tr><td colspan=3>&nbsp</td></tr>\n");
// maximum list entries // maximum list entries
echo ("<tr><td align=\"right\"><b>". echo ("<tr><td align=\"right\"><b>".
_("Maximum list entries") . " : </b></td>". _("Maximum list entries") . " : </b></td>".
@ -500,11 +419,6 @@ echo ("<p><input type=\"hidden\" name=\"passwd\" value=\"" . $passwd . "\"></p>\
// config file // config file
echo ("<p><input type=\"hidden\" name=\"filename\" value=\"" . $filename . "\"></p>\n"); echo ("<p><input type=\"hidden\" name=\"filename\" value=\"" . $filename . "\"></p>\n");
// modules
echo ("<p><input type=\"hidden\" name=\"usermodules\" value=\"" . implode(",", $conf->get_AccountModules('user')) . "\"></p>\n");
echo ("<p><input type=\"hidden\" name=\"groupmodules\" value=\"" . implode(",", $conf->get_AccountModules('group')) . "\"></p>\n");
echo ("<p><input type=\"hidden\" name=\"hostmodules\" value=\"" . implode(",", $conf->get_AccountModules('host')) . "\"></p>\n");
echo ("</form>\n"); echo ("</form>\n");
echo ("</body>\n"); echo ("</body>\n");
echo ("</html>\n"); echo ("</html>\n");

View File

@ -56,30 +56,36 @@ if ($passwd != $conf->get_Passwd()) {
if ($_POST['submit']) { if ($_POST['submit']) {
//selection ok, back to other settings //selection ok, back to other settings
metarefresh('confmain.php?modulesback=true&amp;moduleschanged=true'); metarefresh('confmain.php?modulesback=true&amp;moduleschanged=true');
exit;
} }
elseif ($_POST['abort']) { elseif ($_POST['abort']) {
// no changes // no changes
metarefresh('confmain.php?modulesback=true'); metarefresh('confmain.php?modulesback=true');
exit;
} }
$types = $_SESSION['conf_accountTypes'];
echo $_SESSION['header']; echo $_SESSION['header'];
echo "<title>" . _("LDAP Account Manager Configuration") . "</title>\n"; echo "<title>" . _("LDAP Account Manager Configuration") . "</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n"; echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
for ($i = 0; $i < sizeof($types); $i++){
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/type_" . $types[$i] . ".css\">\n";
}
echo "</head><body>\n"; echo "</head><body>\n";
echo ("<p align=\"center\"><a href=\"http://lam.sourceforge.net\" target=\"new_window\">". echo ("<p align=\"center\"><a href=\"http://lam.sourceforge.net\" target=\"new_window\">".
"<img src=\"../../graphics/banner.jpg\" border=1 alt=\"LDAP Account Manager\"></a></p><hr><br>\n"); "<img src=\"../../graphics/banner.jpg\" border=1 alt=\"LDAP Account Manager\"></a></p><hr><br>\n");
echo ("<form action=\"confmodules.php\" method=\"post\">\n"); echo ("<form action=\"confmodules.php\" method=\"post\">\n");
echo "<p align=\"center\"><big><b>" . _("Module selection") . "</b></big><br><br></p>"; echo "<h1 align=\"center\">" . _("Module selection") . "</h1>";
$account_list = array( $account_list = array();
array('user', _('User modules')), for ($i = 0; $i < sizeof($types); $i++) {
array('group', _('Group modules')), $account_list[] = array($types[$i], getTypeAlias($types[$i]));
array('host', _('Host modules')) }
);
$allDependenciesOk = true; $allDependenciesOk = true;
@ -126,7 +132,8 @@ echo "</html>\n";
*/ */
function config_showAccountModules($scope, $title) { function config_showAccountModules($scope, $title) {
// account modules // account modules
$selected_temp = $_SESSION['conf_' . $scope . 'modules']; $selected_temp = $_SESSION['conf_typeSettings']['modules_' . $scope];
if (isset($selected_temp)) $selected_temp = explode(',', $selected_temp);
$available = array(); $available = array();
$available = getAvailableModules($scope); $available = getAvailableModules($scope);
$selected = array(); $selected = array();
@ -145,7 +152,7 @@ function config_showAccountModules($scope, $title) {
if (! in_array($selected[$i], $_POST[$scope . '_selected'])) $new_selected[] = $selected[$i]; if (! in_array($selected[$i], $_POST[$scope . '_selected'])) $new_selected[] = $selected[$i];
} }
$selected = $new_selected; $selected = $new_selected;
$_SESSION['conf_' . $scope . 'modules'] = $selected; $_SESSION['conf_typeSettings']['modules_' . $scope] = implode(',', $selected);
} }
// add modules to selection // add modules to selection
@ -155,7 +162,7 @@ function config_showAccountModules($scope, $title) {
if (! in_array($_POST[$scope . '_available'][$i], $selected)) $new_selected[] = $_POST[$scope . '_available'][$i]; if (! in_array($_POST[$scope . '_available'][$i], $selected)) $new_selected[] = $_POST[$scope . '_available'][$i];
} }
$selected = $new_selected; $selected = $new_selected;
$_SESSION['conf_' . $scope . 'modules'] = $selected; $_SESSION['conf_typeSettings']['modules_' . $scope] = implode(',', $selected);
} }
// show account modules // show account modules

View File

@ -48,14 +48,7 @@ $passwd2 = $_SESSION['conf_passwd2'];
$serverurl = $_SESSION['conf_serverurl']; $serverurl = $_SESSION['conf_serverurl'];
$cachetimeout = $_SESSION['conf_cachetimeout']; $cachetimeout = $_SESSION['conf_cachetimeout'];
$admins = $_SESSION['conf_admins']; $admins = $_SESSION['conf_admins'];
$suffusers = $_SESSION['conf_suffusers'];
$suffgroups = $_SESSION['conf_suffgroups'];
$suffhosts = $_SESSION['conf_suffhosts'];
$suffdomains = $_SESSION['conf_suffdomains'];
$sufftree = $_SESSION['conf_sufftree']; $sufftree = $_SESSION['conf_sufftree'];
$usrlstattr = $_SESSION['conf_usrlstattr'];
$grplstattr = $_SESSION['conf_grplstattr'];
$hstlstattr = $_SESSION['conf_hstlstattr'];
$maxlistentries = $_SESSION['conf_maxlistentries']; $maxlistentries = $_SESSION['conf_maxlistentries'];
$lang = $_SESSION['conf_lang']; $lang = $_SESSION['conf_lang'];
$scriptpath = $_SESSION['conf_scriptpath']; $scriptpath = $_SESSION['conf_scriptpath'];
@ -81,10 +74,7 @@ echo ("<p align=\"center\"><a href=\"http://lam.sourceforge.net\" target=\"new_w
// remove double slashes if magic quotes are on // remove double slashes if magic quotes are on
if (get_magic_quotes_gpc() == 1) { if (get_magic_quotes_gpc() == 1) {
$suffusers = stripslashes($suffusers); $sufftree = stripslashes($sufftree);
$suffgroups = stripslashes($suffgroups);
$suffhosts = stripslashes($suffhosts);
$suffdomains = stripslashes($suffdomains);
} }
// check new preferences // check new preferences
@ -103,46 +93,11 @@ if (!$conf->set_Adminstring($admins)) {
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>"); echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit; exit;
} }
if (!$conf->set_Suffix('user', $suffusers)) {
echo ("<font color=\"red\"><b>" . _("UserSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_Suffix('group', $suffgroups)) {
echo ("<font color=\"red\"><b>" . _("GroupSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_Suffix('host', $suffhosts)) {
echo ("<font color=\"red\"><b>" . _("HostSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_Suffix('domain', $suffdomains)) {
echo ("<font color=\"red\"><b>" . _("DomainSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_Suffix("tree", $sufftree)) { if (!$conf->set_Suffix("tree", $sufftree)) {
echo ("<font color=\"red\"><b>" . _("TreeSuffix is invalid!") . "</b></font>"); echo ("<font color=\"red\"><b>" . _("TreeSuffix is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>"); echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit; exit;
} }
if (!$conf->set_listAttributes($usrlstattr, 'user')) {
echo ("<font color=\"red\"><b>" . _("User list attributes are invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_listAttributes($grplstattr, 'group')) {
echo ("<font color=\"red\"><b>" . _("Group list attributes are invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_listAttributes($hstlstattr, 'host')) {
echo ("<font color=\"red\"><b>" . _("Host list attributes are invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (!$conf->set_MaxListEntries($maxlistentries)) { if (!$conf->set_MaxListEntries($maxlistentries)) {
echo ("<font color=\"red\"><b>" . _("Max list entries is invalid!") . "</b></font>"); echo ("<font color=\"red\"><b>" . _("Max list entries is invalid!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>"); echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
@ -167,23 +122,8 @@ if (!$conf->set_scriptserver($scriptserver)) {
exit; exit;
} }
if (! $conf->set_AccountModules($_SESSION['conf_usermodules'], 'user')) { $conf->set_typeSettings($_SESSION['conf_typeSettings']);
echo ("<font color=\"red\"><b>" . _("Saving user modules failed!") . "</b></font>"); $conf->set_ActiveTypes($_SESSION['conf_accountTypes']);
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (! $conf->set_AccountModules($_SESSION['conf_groupmodules'], 'group')) {
echo ("<font color=\"red\"><b>" . _("Saving group modules failed!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
if (! $conf->set_AccountModules($_SESSION['conf_hostmodules'], 'host')) {
echo ("<font color=\"red\"><b>" . _("Saving host modules failed!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}
// check module options // check module options
// create option array to check and save // create option array to check and save
@ -249,34 +189,14 @@ if ($passwd1) {
// save settings and display new settings // save settings and display new settings
$conf->save(); $conf->save();
echo ("<b>" . _("The following settings were saved to profile:") . " </b>" . $filename . "<br><br>");
$conf->printconf();
echo ("<br><br><br><br><br><a href=\"../login.php\" target=\"_top\">" . _("Back to Login") . "</a>"); echo ("<br><br><br><br><br><a href=\"../login.php\" target=\"_top\">" . _("Back to Login") . "</a>");
echo("</body></html>"); echo("</body></html>");
// remove settings from session // remove settings from session
unset($_SESSION['conf_passwd']); $sessionKeys = array_keys($_SESSION);
unset($_SESSION['conf_passwd1']); for ($i = 0; $i < sizeof($sessionKeys); $i++) {
unset($_SESSION['conf_passwd2']); if (substr($sessionKeys[$i], 0, 5) == "conf_") unset($_SESSION[$sessionKeys[$i]]);
unset($_SESSION['conf_serverurl']); }
unset($_SESSION['conf_cachetimeout']);
unset($_SESSION['conf_admins']);
unset($_SESSION['conf_suffusers']);
unset($_SESSION['conf_suffgroups']);
unset($_SESSION['conf_suffhosts']);
unset($_SESSION['conf_suffdomains']);
unset($_SESSION['conf_sufftree']);
unset($_SESSION['conf_usrlstattr']);
unset($_SESSION['conf_grplstattr']);
unset($_SESSION['conf_hstlstattr']);
unset($_SESSION['conf_maxlistentries']);
unset($_SESSION['conf_lang']);
unset($_SESSION['conf_scriptpath']);
unset($_SESSION['conf_scriptserver']);
unset($_SESSION['conf_filename']);
unset($_SESSION['conf_usermodules']);
unset($_SESSION['conf_groupmodules']);
unset($_SESSION['conf_hostmodules']);
?> ?>

View File

@ -0,0 +1,224 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2004 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
*/
/**
* Here the user can select the account types.
*
* @package configuration
* @author Roland Gruber
*/
/** Access to config functions */
include_once ('../../lib/config.inc');
/** Access to account types */
include_once ('../../lib/types.inc');
// start session
session_save_path("../../sess");
@session_start();
setlanguage();
$conf = new Config($_SESSION['conf_filename']);
$passwd = $_SESSION['conf_passwd'];
// check if password is correct
// if not: load login page
if ($passwd != $conf->get_Passwd()) {
/** go back to login if password is invalid */
require('conflogin.php');
exit;
}
// update type settings
if (isset($_POST['postAvailable'])) {
$postKeys = array_keys($_POST);
for ($i = 0; $i < sizeof($postKeys); $i++) {
$key = $postKeys[$i];
if (substr($key, 0, 7) == "suffix_") {
$_SESSION['conf_typeSettings'][$key] = $_POST[$key];
}
elseif (substr($key, 0, 5) == "attr_") {
$_SESSION['conf_typeSettings'][$key] = $_POST[$key];
}
}
}
$errors = array();
// user pressed submit/abort button
if ($_POST['submit']) {
// check settings
$allOK = true;
$postKeys = array_keys($_POST);
for ($i = 0; $i < sizeof($postKeys); $i++) {
$key = $postKeys[$i];
if (substr($key, 0, 7) == "suffix_") {
$type = substr($postKeys[$i], 7);
if (strlen($_POST[$key]) < 1) {
$errors[] = array("ERROR", _("LDAP Suffix is invalid!"), getTypeAlias($type));
$allOK = false;
}
}
elseif (substr($key, 0, 5) == "attr_") {
$type = substr($postKeys[$i], 5);
if (!is_string($_POST[$key]) || !eregi("^((#[^:;]+)|([^:;]*:[^:;]+))(;((#[^:;]+)|([^:;]*:[^:;]+)))*$", $_POST[$key])) {
$errors[] = array("ERROR", _("List attributes are invalid!"), getTypeAlias($type));
$allOK = false;
}
}
}
if ($allOK) {
//selection ok, back to other settings
metarefresh('confmain.php?typesback=true&amp;typeschanged=true');
exit;
}
}
elseif ($_POST['abort']) {
// no changes
metarefresh('confmain.php?typesback=true');
exit;
}
// check if remove button was pressed
$postKeys = array_keys($_POST);
for ($i = 0; $i < sizeof($postKeys); $i++) {
$key = $postKeys[$i];
if (substr($key, 0, 4) == "rem_") {
$type = substr($key, 4);
$_SESSION['conf_accountTypes'] = array_flip($_SESSION['conf_accountTypes']);
unset($_SESSION['conf_accountTypes'][$type]);
$_SESSION['conf_accountTypes'] = array_flip($_SESSION['conf_accountTypes']);
$_SESSION['conf_accountTypes'] = array_values($_SESSION['conf_accountTypes']);
}
}
// check if add button was pressed
$postKeys = array_keys($_POST);
for ($i = 0; $i < sizeof($postKeys); $i++) {
$key = $postKeys[$i];
if (substr($key, 0, 4) == "add_") {
$type = substr($key, 4);
$_SESSION['conf_accountTypes'][] = $type;
}
}
// get active and available types
$allTypes = getTypes();
$activeTypes = $_SESSION['conf_accountTypes'];
$availableTypes = array();
for ($i = 0; $i < sizeof($allTypes); $i++) {
if (!in_array($allTypes[$i], $activeTypes)) $availableTypes[] = $allTypes[$i];
}
echo $_SESSION['header'];
echo "<title>" . _("LDAP Account Manager Configuration") . "</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
for ($i = 0; $i < sizeof($allTypes); $i++){
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/type_" . $allTypes[$i] . ".css\">\n";
}
echo "</head><body>\n";
echo ("<p align=\"center\"><a href=\"http://lam.sf.net\" target=\"new_window\">".
"<img src=\"../../graphics/banner.jpg\" border=1 alt=\"LDAP Account Manager\"></a></p><hr><br>\n");
// print error messages
for ($i = 0; $i < sizeof($errors); $i++) call_user_func_array('StatusMessage', $errors[$i]);
echo ("<form action=\"conftypes.php\" method=\"post\">\n");
echo "<h1 align=\"center\">" . _("Account type selection") . "</h1>";
// show available types
echo "<fieldset><legend><b>" . _("Available account types") . "</b></legend>\n";
echo "<table>\n";
for ($i = 0; $i < sizeof($availableTypes); $i++) {
echo "<tr>\n";
echo "<td><b>" . getTypeAlias($availableTypes[$i]) . ": </b></td>\n";
echo "<td>" . getTypeDescription($availableTypes[$i]) . "</td>\n";
echo "<td><input type=\"submit\" name=\"add_" . $availableTypes[$i] ."\" value=\"" . _("Add") . "\"></td>\n";
echo "</tr>\n";
}
echo "</table>\n";
echo "</fieldset>\n";
echo "<p><br><br></p>";
// show active types
echo "<fieldset><legend><b>" . _("Active account types") . "</b></legend><br>\n";
for ($i = 0; $i < sizeof($activeTypes); $i++) {
echo "<fieldset class=\"" . $activeTypes[$i] . "edit\">\n";
echo "<legend>" . "<b>" . getTypeAlias($activeTypes[$i]) . ": </b>" . getTypeDescription($activeTypes[$i]) . "</legend>";
echo "<br>\n";
echo "<table>\n";
// LDAP suffix
echo "<tr>\n";
echo "<td>" . _("LDAP suffix") . "</td>\n";
echo "<td><input type=\"text\" size=\"40\" name=\"suffix_" . $activeTypes[$i] . "\" value=\"" . $_SESSION['conf_typeSettings']['suffix_' . $activeTypes[$i]] . "\"></td>\n";
echo "</tr>\n";
// list attributes
if (isset($_SESSION['conf_typeSettings']['attr_' . $activeTypes[$i]])) {
$attributes = $_SESSION['conf_typeSettings']['attr_' . $activeTypes[$i]];
}
else {
$attributes = getDefaultListAttributes($activeTypes[$i]);
}
echo "<tr>\n";
echo "<td>" . _("List attributes") . "</td>\n";
echo "<td><input type=\"text\" size=\"40\" name=\"attr_" . $activeTypes[$i] . "\" value=\"" . $attributes . "\"></td>\n";
echo "</tr>\n";
echo "<tr><td colspan=\"2\">&nbsp;</td></tr>\n";
// remove button
echo "<tr>\n";
echo "<td colspan=\"2\"><input type=\"submit\" name=\"rem_" . $activeTypes[$i] . "\" value=\"" . _("Remove this account type") . "\"></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</fieldset><br>\n";
}
echo "</fieldset>\n";
echo "<p><br><br></p>\n";
// submit and abort button
echo "<p>";
echo "<input type=\"submit\" name=\"submit\" value=\"" . _("Submit") . "\">\n";
echo "<input type=\"submit\" name=\"abort\" value=\"" . _("Abort") . "\">\n";
echo "<input type=\"hidden\" name=\"postAvailable\" value=\"yes\">\n";
echo "</p>";
echo "<p><br><br></p>\n";
echo "</form>\n";
echo "</body>\n";
echo "</html>\n";
?>

View File

@ -1,357 +0,0 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2003 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
*/
/**
* Manages Samba 3 domain entries.
*
* @package tools
* @author Roland Gruber
*/
/** access to configuration options */
include_once ("../lib/config.inc");
/** access to LDAP server */
include_once ("../lib/ldap.inc");
/** Samba 3 domain object */
include_once ("../lib/account.inc");
// start session
session_save_path("../sess");
@session_start();
setlanguage();
// add/edit domain
if (($_GET['action'] == "edit") || ($_GET['action'] == "new")) {
// get list of domains
$domlist = search_domains($_SESSION['config']->get_Suffix('domain'));
// get possible suffixes
$domsuff = $_SESSION['ldap']->search_units($_SESSION['config']->get_Suffix('domain'));
if ($_GET['action'] == "edit") {
// remove "\'"
$_GET['DN'] = str_replace("\\", "", $_GET['DN']);
$_GET['DN'] = str_replace("'", "", $_GET['DN']);
// load attributes from domain
for ($i = 0; $i < sizeof($domlist); $i++) {
if ($domlist[$i]->dn == $_GET['DN']) {
$domain = $domlist[$i];
break;
}
}
// get suffix
$tmp_arr = explode(",", $domain->dn);
array_shift($tmp_arr);
$domain_suffix = implode(",", $tmp_arr);
}
else {
$domain = new samba3domain();
$domain_suffix = $_SESSION['config']->get_Suffix('domain');
}
// display page
echo $_SESSION['header'];
echo "<title>Domain Management</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\">\n";
echo "</head>\n";
echo "<body>\n";
// print message, if needed
if ($_SESSION['domain_message']) StatusMessage("INFO", $_SESSION['domain_message'], "");
// print fieldset
echo "<form action=\"domain.php\" method=\"post\">\n";
echo "<p>&nbsp;</p>\n";
echo "<fieldset class=\"domedit\">\n";
echo "<legend class=\"domedit\"><b>" . _("Domain Settings") . "</b></legend>\n";
echo "<table border=0>\n";
// domain name
echo "<tr>\n";
echo "<td>\n";
echo "<b>" . _("Domain name") . ":</b>\n";
echo "</td>\n";
echo "<td>\n";
if ($_GET['action'] == "edit") {
echo $domain->name . "\n";
}
else echo "<input tabindex=\"1\" type=\"text\" name=\"dom_name\">\n";
echo "</td>\n";
echo ("<td>");
// help link
echo "<a href=\"help.php?HelpNumber=651\" target=\"lamhelp\">";
echo "<img src=\"../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
echo "</a>\n";
echo ("</td>\n");
echo "</tr>\n";
echo "<tr>\n";
echo "<td>&nbsp;</td><td>&nbsp;</td>\n";
echo "</tr>\n";
// domain SID
echo "<tr>\n";
echo "<td>\n";
echo "<b>" . _("Domain SID") . ": </b>\n";
echo "</td>\n";
echo "<td>\n";
if ($_GET['action'] == "edit") {
echo $domain->SID . "\n";
}
else echo "<input tabindex=\"2\" type=\"text\" size=\"50\" name=\"dom_SID\">\n";
echo "</td>\n";
echo "<td>";
// help link
echo "<a href=\"help.php?HelpNumber=653\" target=\"lamhelp\">";
echo "<img src=\"../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
echo "</a>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>&nbsp;</td><td>&nbsp;</td>\n";
echo "</tr>\n";
// next RID
echo "<tr>\n";
echo "<td><b>" . _("Next RID") . ": </b></td>\n";
echo "<td>\n";
echo "<input tabindex=\"3\" type=\"text\" name=\"dom_nextRID\" value=\"" . $domain->nextRID . "\">\n";
echo "</td>\n";
echo "<td>";
// help link
echo "<a href=\"help.php?HelpNumber=654\" target=\"lamhelp\">";
echo "<img src=\"../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
echo "</a>\n";
echo "</td>\n";
echo "</tr>\n";
// next user RID
echo "<tr>\n";
echo "<td><b>" . _("Next User RID") . ": </b></td>\n";
echo "<td>\n";
echo "<input tabindex=\"4\" type=\"text\" name=\"dom_nextUserRID\" value=\"" . $domain->nextUserRID . "\">\n";
echo "</td>\n";
echo "<td>";
// help link
echo "<a href=\"help.php?HelpNumber=655\" target=\"lamhelp\">";
echo "<img src=\"../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
echo "</a>\n";
echo "</td>\n";
echo "</tr>\n";
// next group RID
echo "<tr>\n";
echo "<td><b>" . _("Next Group RID") . ": </b></td>\n";
echo "<td>\n";
echo "<input tabindex=\"5\" type=\"text\" name=\"dom_nextGroupRID\" value=\"" . $domain->nextGroupRID . "\">\n";
echo "</td>\n";
echo "<td>";
// help link
echo "<a href=\"help.php?HelpNumber=656\" target=\"lamhelp\">";
echo "<img src=\"../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
echo "</a>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>&nbsp;</td><td>&nbsp;</td>\n";
echo "</tr>\n";
// algorithmic RID base
echo "<tr>\n";
echo "<td><b>" . _("Algorithmic RID Base") . ": </b></td>\n";
echo "<td>\n";
if ($_GET['action'] == "edit") echo $domain->RIDbase . "\n";
else echo "<input tabindex=\"6\" type=\"text\" name=\"dom_RIDbase\" value=\"" . $domain->RIDbase . "\">\n";
echo "</td>\n";
echo "<td>";
// help link
echo "<a href=\"help.php?HelpNumber=657\" target=\"lamhelp\">";
echo "<img src=\"../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
echo "</a>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>&nbsp;</td><td>&nbsp;</td>\n";
echo "</tr>\n";
// domain suffix
echo "<tr>\n";
echo "<td>\n";
echo "<b>" . _("Suffix") . ": </b>\n";
echo "</td>\n";
echo "<td>\n";
echo "<select tabindex=\"7\" name=\"dom_suffix\">\n";
for ($i = 0; $i < sizeof($domsuff); $i++) {
if ($domsuff[$i] == $domain_suffix) echo "<option selected>" . $domain_suffix . "</option>\n";
else echo "<option>" . $domsuff[$i] . "</option>\n";
}
echo "</select>";
echo "</td>\n";
echo "<td>";
// help link
echo "<a href=\"help.php?HelpNumber=652\" target=\"lamhelp\">";
echo "<img src=\"../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
echo "</a>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>&nbsp;</td><td>&nbsp;</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</fieldset>\n";
// post DN and old RID values
echo "<input type=\"hidden\" name=\"dom_DN\" value=\"" . $domain->dn . "\">";
echo "<input type=\"hidden\" name=\"dom_oldnextRID\" value=\"" . $domain->nextRID . "\">";
echo "<input type=\"hidden\" name=\"dom_oldnextUserRID\" value=\"" . $domain->nextUserRID . "\">";
echo "<input type=\"hidden\" name=\"dom_oldnextGroupRID\" value=\"" . $domain->nextGroupRID . "\">";
// edit or add operation
if ($_GET['action'] == "edit") echo "<input type=\"hidden\" name=\"edit\" value=\"yes\">";
else echo "<input type=\"hidden\" name=\"add\" value=\"yes\">";
echo "<p>&nbsp;</p>\n";
echo "<p>\n";
echo "<input tabindex=\"8\" type=\"submit\" name=\"sub_save\" value=\"" . _("Submit") . "\">\n";
echo "<input tabindex=\"9\" type=\"reset\" value=\"" . _("Reset") . "\">\n";
echo "<input tabindex=\"10\" type=\"submit\" name=\"sub_back\" value=\"" . _("Cancel") . "\">\n";
echo "</p>\n";
echo "</form>\n";
echo "</body>\n";
echo "</html>\n";
}
// delete domain, ask if sure
elseif ($_GET['action'] == "delete") {
// remove "\'" and make array
$DNs = str_replace("\\", "", $_GET['DN']);
$DNs = str_replace("'", "", $DNs);
$DNs = explode(";", $DNs);
// display page
echo $_SESSION['header'];
echo "<title>Domain Management</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\">\n";
echo "</head>\n";
echo "<body>\n";
echo "<p>&nbsp;</p>\n";
echo "<fieldset class=\"domedit\"><legend class=\"domedit\"><b>" . _("Delete domain(s)") . "</b></legend>\n";
echo "<p><b>" . _("Do you really want to delete domain(s):") . "</b></p>\n";
echo "<p>&nbsp;</p>\n";
for ($i = 0; $i < sizeof($DNs); $i++) {
echo "<p>" . $DNs[$i] . "</p>\n";
}
echo "<p>&nbsp;</p>\n";
echo "<form action=\"domain.php\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"delDN\" value=\"" . implode(";", $DNs) . "\">\n";
echo "<input type=\"submit\" name=\"sub_delete\" value=\"" . _("Delete") . "\">\n";
echo "<input type=\"submit\" name=\"sub_back\" value=\"" . _("Cancel") . "\">\n";
echo "</form>\n";
echo "</fieldset>\n";
echo "</body>\n";
echo "</html>\n";
}
// save domain
elseif ($_POST['sub_save']) {
echo $_SESSION['header'];
echo "<title>Domain Management</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\">\n";
echo "</head>\n";
echo "<body>\n";
// check input
if ($_POST['add']) { // check for existing domains
$suffix = $_SESSION['config']->get_Suffix('domain');
$server = $_SESSION['ldap']->server;
$filter = "(|(sambasid=" . $_POST['dom_SID'] . ")(sambadomainname=" . $_POST['dom_name'] . "))";
$sr = @ldap_search($server, $suffix, $filter, array());
$info = @ldap_get_entries($_SESSION["ldap"]->server, $sr);
}
if ($_POST['add'] && !eregi("^[a-z0-9_\\-]+$", $_POST['dom_name'])) StatusMessage("ERROR", "", _("Domain name is invalid!"));
elseif ($_POST['add'] && !eregi("^S-[0-9]-[0-9]-[0-9]{2,2}-[0-9]*-[0-9]*-[0-9]*$", $_POST['dom_SID'])) {
StatusMessage("ERROR", "", _("Samba 3 domain SID is invalid!"));
}
elseif ($_POST['add'] && ($info["count"] > 0)) {
StatusMessage("ERROR", "", _("This Samba 3 domain is already present!"));
}
elseif ($_POST['dom_nextRID'] && !is_numeric($_POST['dom_nextRID'])) StatusMessage("ERROR", "", _("Next RID is not a number!"));
elseif ($_POST['dom_nextUserRID'] && !is_numeric($_POST['dom_nextUserRID'])) StatusMessage("ERROR", "", _("Next user RID is not a number!"));
elseif ($_POST['dom_nextGroupRID'] && !is_numeric($_POST['dom_nextGroupRID'])) StatusMessage("ERROR", "", _("Next group RID is not a number!"));
elseif ($_POST['add'] && !is_numeric($_POST['dom_RIDbase'])) StatusMessage("ERROR", "", _("Algorithmic RID base is not a number!"));
// edit entry
elseif ($_POST['edit'] == "yes") {
$success = true;
// change attributes
$attr = array();
if ($_POST['dom_nextRID'] != $_POST['dom_oldnextRID']) $attr['sambaNextRid'] = $_POST['dom_nextRID'];
if ($_POST['dom_nextUserRID'] != $_POST['dom_oldnextUserRID']) $attr['sambaNextUserRid'] = $_POST['dom_nextUserRID'];
if ($_POST['dom_nextGroupRID'] != $_POST['dom_oldnextGroupRID']) $attr['sambaNextGroupRid'] = $_POST['dom_nextGroupRID'];
if (sizeof($attr) > 0) $success = ldap_modify($_SESSION['ldap']->server(), $_POST['dom_DN'], $attr);
// change suffix
$RDN = explode(",", $_POST['dom_DN']);
$RDN = $RDN[0];
$newDN = $RDN . "," . $_POST['dom_suffix'];
if ($_POST['dom_DN'] != $newDN) {
$success = ldap_rename($_SESSION['ldap']->server(), $_POST['dom_DN'], $RDN, $_POST['dom_suffix'], true);
}
if ($success) StatusMessage("INFO", _("Domain has been modified."), $_POST['dom_DN']);
else StatusMessage("ERROR", "", _("Failed to modify domain!"));
}
// add entry
else {
$DN = "sambaDomainName" . "=" . $_POST['dom_name'] . "," . $_POST['dom_suffix'];
$attr = array();
$attr['objectclass'] = "sambaDomain";
$attr['sambaDomainName'] = $_POST['dom_name'];
$attr['sambaSID'] = $_POST['dom_SID'];
if ($_POST['dom_nextRID']) $attr['sambaNextRid'] = $_POST['dom_nextRID'];
if ($_POST['dom_nextGroupRID']) $attr['sambaNextGroupRid'] = $_POST['dom_nextGroupRID'];
if ($_POST['dom_nextUserRID']) $attr['sambaNextUserRid'] = $_POST['dom_nextUserRID'];
$attr['sambaAlgorithmicRidBase'] = $_POST['dom_RIDbase'];
// write to LDAP
if (@ldap_add($_SESSION['ldap']->server(), $DN, $attr)) {
StatusMessage("INFO", "Domain has been created.", $DN);
}
else StatusMessage("ERROR", "", _("Failed to add domain!") . "\n<br>" . ldap_error($_SESSION['ldap']->server()));
}
echo "<p>&nbsp;</p>\n";
echo "<p><a href=\"lists/listdomains.php\">" . _("Back to domain list") . "</a></p>\n";
echo "</body>\n";
echo "</html>\n";
}
// back to list
elseif ($_POST['sub_back']) {
metaRefresh("lists/listdomains.php");
}
// delete domain, user was sure
elseif ($_POST['sub_delete']) {
$DNs = explode(";", $_POST['delDN']);
// display page
echo $_SESSION['header'];
echo "<title>Domain Management</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\">\n";
echo "</head>\n";
echo "<body>\n";
// delete DNs
for ($i = 0; $i < sizeof($DNs); $i++) {
if (ldap_delete($_SESSION['ldap']->server(), $DNs[$i])) StatusMessage("INFO", _("Domain deleted successfully."), $DNs[$i]);
else StatusMessage("ERROR", _("Unable to delete domain!"), $DNs[$i]);
}
echo "<p>&nbsp;</p>\n";
echo "<p><a href=\"lists/listdomains.php\">" . _("Back to domain list") . "</a></p>\n";
echo "</body>\n";
echo "</html>\n";
}
?>

View File

@ -0,0 +1,55 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2003 - 2004 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
*/
/**
* This file shows the list views.
*
* @package lists
* @author Roland Gruber
*/
/** Used to get type information. */
include_once("../../lib/types.inc");
/** Access to configuration options */
include_once ("../../lib/config.inc");
// start session
session_save_path("../../sess");
@session_start();
setlanguage();
// create list object if needed
$type = $_GET['type'];
$listClass = getListClassName($type);
if (!isset($_SESSION['list_' . $type])) {
$list = new $listClass($type);
$_SESSION['list_' . $type] = $list;
}
// show page
$_SESSION['list_' . $type]->showPage();
?>

View File

@ -1,222 +0,0 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2003 - 2004 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 detaexils.
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
*/
/**
* This page displays a list of all Samba domains.
*
* @package tools
* @author Roland Gruber
*/
/** Access to configuration options */
include_once("../../lib/config.inc");
/** Access to LDAP connection */
include_once("../../lib/ldap.inc");
/** Used to print status messages */
include_once("../../lib/status.inc");
/** Basic list functions */
include_once("../../lib/lists.inc");
// start session
session_save_path("../../sess");
@session_start();
setlanguage();
$scope = 'domain';
// copy HTTP-GET variables to HTTP-POST
$_POST = $_POST + $_GET;
if (isset($_SESSION[$scope . 'info'])) $info = $_SESSION[$scope . 'info'];
if (isset($_SESSION[$scope . '_units'])) $units = $_SESSION[$scope . '_units'];
// check if button was pressed and if we have to add/delete a domain
if (isset($_POST['new']) || isset($_POST['del'])){
// add new domain
if (isset($_POST['new'])){
metaRefresh("../domain.php?action=new");
exit;
}
// delete domain(s)
if (isset($_POST['del'])){
// search for checkboxes
$domains = array_keys($_POST, "on");
$domainstr = implode(";", $domains);
if ($domainstr) {
metaRefresh("../domain.php?action=delete&amp;DN='$domainstr'");
exit;
}
}
}
echo $_SESSION['header'];
echo "<title>listdomains</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
echo "</head><body>\n";
listPrintJavaScript();
// get current page
if (isset($_GET["page"])) $page = $_GET["page"];
else $page = 1;
// take maximum count of domain entries shown on one page out of session
if ($_SESSION["config"]->get_MaxListEntries() <= 0)
$max_page_entries = 10; // default setting, if not yet set
else
$max_page_entries = $_SESSION["config"]->get_MaxListEntries();
// generate attribute and description tables
$attr_array = array(); // list of LDAP attributes to show
$desc_array = array(); // list of descriptions for the attributes
$attr_array[] = "sambaDomainName";
$attr_array[] = "sambaSID";
$attr_array[] = "dn";
$desc_array[] = strtoupper(_("Domain name"));
$desc_array[] = strtoupper(_("Domain SID"));
$desc_array[] = "DN";
if (isset($_GET["sort"])) $sort = $_GET["sort"];
else $sort = strtolower($attr_array[0]);
// check search suffix
if (isset($_POST['suffix'])) $suffix = $_POST['suffix']; // new suffix selected via combobox
elseif (isset($_SESSION[$scope . '_suffix'])) $suffix = $_SESSION[$scope . '_suffix']; // old suffix from session
else $suffix = $_SESSION["config"]->get_Suffix($scope); // default suffix
$refresh = true;
if (isset($_GET['norefresh'])) $refresh = false;
if (isset($_POST['refresh'])) $refresh = true;
if ($refresh) {
// configure search filter
$filter = "(objectClass=sambaDomain)";
$attrs = $attr_array;
$sr = @ldap_search($_SESSION["ldap"]->server(), $suffix, $filter, $attrs);
if (ldap_errno($_SESSION["ldap"]->server()) == 4) {
StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem."));
}
if ($sr) {
$info = ldap_get_entries($_SESSION["ldap"]->server, $sr);
ldap_free_result($sr);
if ($info["count"] == 0) StatusMessage("WARN", "", _("No Samba domains found!"));
// delete first array entry which is "count"
unset($info['count']);
// sort rows by sort column ($sort)
$info = listSort($sort, $attr_array, $info);
}
else StatusMessage("ERROR", _("LDAP Search failed! Please check your preferences."), _("No Samba domains found!"));
}
// use search result from session
else {
if (sizeof($info) == 0) StatusMessage("WARN", "", _("No Samba domains found!"));
// sort rows by sort column ($sort)
if ($info) $info = listSort($sort, $attr_array, $info);
}
echo ("<form action=\"listdomains.php?norefresh=true\" method=\"post\">\n");
// draw navigation bar if domain accounts were found
if (sizeof($info) > 0) {
listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, '', "domain", _("%s Samba domain(s) found"));
echo ("<br>\n");
}
// print domain table header
echo "<table rules=\"all\" class=\"domainlist\" width=\"100%\">\n";
echo "<tr class=\"domainlist-head\"><th width=22 height=34></th><th></th>";
// table header
for ($k = 0; $k < sizeof($desc_array); $k++) {
if (strtolower($attr_array[$k]) == $sort) {
echo "<th class=\"domainlist-sort\"><a href=\"listdomains.php?".
"sort=" . strtolower($attr_array[$k]) . "&amp;norefresh=y" . "\">" . $desc_array[$k] . "</a></th>";
}
else echo "<th><a href=\"listdomains.php?".
"sort=" . strtolower($attr_array[$k]) . "&amp;norefresh=y" . "\">" . $desc_array[$k] . "</a></th>";
}
echo "</tr>\n";
// calculate which rows to show
$table_begin = ($page - 1) * $max_page_entries;
if (($page * $max_page_entries) > sizeof($info)) $table_end = sizeof($info);
else $table_end = ($page * $max_page_entries);
// print domain list
for ($i = $table_begin; $i < $table_end; $i++) {
echo("<tr class=\"domainlist\" onMouseOver=\"list_over(this, '" . $info[$i]["dn"] . "', '" . $scope . "')\"" .
" onMouseOut=\"list_out(this, '" . $info[$i]["dn"] . "', '" . $scope . "')\"" .
" onClick=\"list_click(this, '" . $info[$i]["dn"] . "', '" . $scope . "')\"" .
" onDblClick=\"parent.frames[1].location.href='../domain.php?action=edit&amp;DN=" . $info[$i]["dn"] . "'\">" .
" <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $info[$i]["dn"] . "', '" . $scope . "')\" type=\"checkbox\" name=\"" . $info[$i]["dn"] . "\"></td>" .
" <td align='center'><a href=\"../domain.php?action=edit&amp;DN='" . $info[$i]["dn"] . "'\">" . _("Edit") . "</a></td>");
for ($k = 0; $k < sizeof($attr_array); $k++) {
echo ("<td>");
// print all attribute entries seperated by "; "
if (sizeof($info[$i][strtolower($attr_array[$k])]) > 0) {
// delete first array entry which is "count"
if (is_array($info[$i][strtolower($attr_array[$k])])) unset($info[$i][strtolower($attr_array[$k])]['count']);
if (is_array($info[$i][strtolower($attr_array[$k])])) echo implode("; ", $info[$i][strtolower($attr_array[$k])]);
else echo $info[$i][strtolower($attr_array[$k])];
}
echo ("</td>");
}
echo("</tr>\n");
}
echo ("</table>");
echo ("<br>");
// draw navigation bar if domain accounts were found
if (sizeof($info) > 0) {
listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, '', "domain", _("%s Samba domain(s) found"));
echo ("<br>\n");
}
if ($refresh) {
// generate list of possible suffixes
$units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($scope));
}
// print combobox with possible sub-DNs
listShowOUSelection($units, $suffix);
echo ("<p align=\"left\">\n");
echo ("<input type=\"submit\" name=\"new\" value=\"" . _("New Domain") . "\">\n");
if (sizeof($info) > 0) echo ("<input type=\"submit\" name=\"del\" value=\"" . _("Delete Domain(s)") . "\">\n");
echo ("</p>\n");
echo ("</form>\n");
echo "</body></html>\n";
// save variables to session
$_SESSION[$scope . 'info'] = $info;
$_SESSION[$scope . '_units'] = $units;
$_SESSION[$scope . '_suffix'] = $suffix;
?>

View File

@ -1,261 +0,0 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2003 - 2004 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 detaexils.
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
*/
/**
* This page displays a list of all groups.
*
* @package lists
* @author Roland Gruber
*/
/** Access to configuration options */
include_once ("../../lib/config.inc");
/** Access to LDAP connection */
include_once ("../../lib/ldap.inc");
/** Used to print status messages */
include_once ("../../lib/status.inc");
/** Used to create PDF files */
include_once("../../lib/pdf.inc");
/** Access to account modules */
include_once("../../lib/modules.inc");
/** Basic list functions */
include_once("../../lib/lists.inc");
// start session
session_save_path("../../sess");
@session_start();
setlanguage();
$scope = 'group';
// copy HTTP-GET variables to HTTP-POST
$_POST = $_POST + $_GET;
if (isset($_SESSION[$scope . 'info'])) $info = $_SESSION[$scope . 'info'];
if (isset($_SESSION[$scope . '_units'])) $units = $_SESSION[$scope . '_units'];
listDoPost($scope);
echo $_SESSION['header'];
echo "<title>listgroups</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
echo "</head><body>\n";
listPrintJavaScript();
// generate attribute-description table
$temp_array = listGetAttributeDescriptionList($scope);
$attr_array = array_keys($temp_array); // list of LDAP attributes to show
$desc_array = array_values($temp_array); // list of descriptions for the attributes
// get current page
if (isset($_GET["page"])) $page = $_GET["page"];
else $page = 1;
// take maximum count of group entries shown on one page out of session
if ($_SESSION["config"]->get_MaxListEntries() <= 0)
$max_page_entries = 10; // default setting, if not yet set
else
$max_page_entries = $_SESSION["config"]->get_MaxListEntries();
// get sorting column
if (isset($_GET["sort"])) $sort = $_GET["sort"];
else $sort = strtolower($attr_array[0]);
// check search suffix
if ($_POST['suffix']) $suffix = $_POST['suffix']; // new suffix selected via combobox
elseif ($_SESSION[$scope . '_suffix']) $suffix = $_SESSION[$scope . '_suffix']; // old suffix from session
else $suffix = $_SESSION["config"]->get_Suffix($scope); // default suffix
$refresh = true;
if (isset($_GET['norefresh'])) $refresh = false;
if (isset($_POST['refresh'])) $refresh = true;
if ($refresh) {
// configure search filter
$module_filter = get_ldap_filter($scope); // basic filter is provided by modules
$filter = "(&" . $module_filter . ")";
$attrs = $attr_array;
$sr = @ldap_search($_SESSION["ldap"]->server(), $suffix, $filter, $attrs);
if (ldap_errno($_SESSION["ldap"]->server()) == 4) {
StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem."));
}
if ($sr) {
$info = ldap_get_entries($_SESSION["ldap"]->server, $sr);
ldap_free_result($sr);
// delete first array entry which is "count"
unset($info['count']);
// save position in original $info
for ($i = 0; $i < sizeof($info); $i++) $info[$i]['LAM_ID'] = $i;
// save results
$_SESSION[$scope . 'info'] = $info;
}
else {
$info = array();
$_SESSION[$scope . 'info'] = array();
StatusMessage("ERROR", _("LDAP Search failed! Please check your preferences."), _("No groups found!"));
}
}
$filter = listBuildFilter($attr_array);
$info = listFilterAccounts($info, $filter);
if (sizeof($info) == 0) StatusMessage("WARN", "", _("No groups found!"));
// sort rows by sort column ($sort)
if ($info) {
$info = listSort($sort, $attr_array, $info);
}
// build filter URL
$searchFilter = array();
$filterAttributes = array_keys($filter);
for ($i = 0; $i < sizeof($filterAttributes); $i++) {
$searchFilter[] = "filter" . $filterAttributes[$i] . "=" . $filter[$filterAttributes[$i]]['original'];
}
if (sizeof($searchFilter) > 0) {
$searchFilter = "&amp;" . implode("&amp;", $searchFilter);
}
else {
$searchFilter = "";
}
echo ("<form action=\"listgroups.php?norefresh=true\" method=\"post\">\n");
// draw navigation bar if group accounts were found
if (sizeof($info) > 0) {
listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, $searchFilter, $scope, _("%s group(s) found"));
echo ("<br>");
}
// account table head
listPrintTableHeader($scope, $searchFilter, $desc_array, $attr_array, $_POST, $sort);
// calculate which rows to show
$table_begin = ($page - 1) * $max_page_entries;
if (($page * $max_page_entries) > sizeof($info)) $table_end = sizeof($info);
else $table_end = ($page * $max_page_entries);
if (sizeof($info) > 0) {
// print group list
for ($i = $table_begin; $i < $table_end; $i++) {
echo("<tr class=\"grouplist\" onMouseOver=\"list_over(this, '" . $info[$i]['LAM_ID'] . "', '" . $scope . "')\"\n" .
" onMouseOut=\"list_out(this, '" . $info[$i]['LAM_ID'] . "', '" . $scope . "')\"\n" .
" onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $scope . "')\"\n" .
" onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=group&amp;DN=" . $info[$i]['dn'] . "'\">\n");
if (isset($_GET['selectall'])) {
echo " <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $scope . "')\" type=\"checkbox\"" .
" name=\"" . $info[$i]['LAM_ID'] . "\" checked></td>\n";
}
else {
echo " <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $scope . "')\" type=\"checkbox\"" .
" name=\"" . $info[$i]['LAM_ID'] . "\"></td>\n";
}
echo (" <td align='center'><a href=\"../account/edit.php?type=group&amp;DN='" . $info[$i]['dn'] . "'\">" . _("Edit") . "</a></td>\n");
for ($k = 0; $k < sizeof($attr_array); $k++) {
echo ("<td>");
// print all attribute entries seperated by "; "
$attrName = strtolower($attr_array[$k]);
if (isset($info[$i][$attrName]) && sizeof($info[$i][$attrName]) > 0) {
// delete first array entry which is "count"
if (is_array($info[$i][$attrName])) unset($info[$i][$attrName]['count']);
// generate links for group members
if ($attrName == "memberuid") {
// sort array
sort($info[$i][$attrName]);
// make a link for each member of the group
$linklist = array();
for ($d = 0; $d < sizeof($info[$i][$attrName]); $d++) {
$user = $info[$i][$attrName][$d]; // user name
$linklist[$d] = "<a href=\"userlink.php?user='" . $user . "' \">" . $user . "</a>";
}
echo implode("; ", $linklist);
}
// print all other attributes
else {
if (is_array($info[$i][$attrName])) {
// delete "count" entry
unset($info[$i][$attrName]['count']);
// sort array
sort($info[$i][$attrName]);
echo implode("; ", $info[$i][$attrName]);
}
else echo $info[$i][$attrName];
}
}
echo ("</td>\n");
}
echo("</tr>\n");
}
// display select all link
$colspan = sizeof($attr_array) + 1;
echo "<tr class=\"grouplist\">\n";
echo "<td align=\"center\"><img src=\"../../graphics/select.png\" alt=\"select all\"></td>\n";
echo "<td colspan=$colspan>&nbsp;<a href=\"listgroups.php?norefresh=y&amp;page=" . $page . "&amp;sort=" . $sort .
$searchFilter . "&amp;selectall=yes\">" .
"<font color=\"black\"><b>" . _("Select all") . "</b></font></a></td>\n";
echo "</tr>\n";
}
echo ("</table>");
echo ("<br>");
// draw navigation bar if group accounts were found
if (sizeof($info) > 0) {
listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, $searchFilter, $scope, _("%s group(s) found"));
echo ("<br>\n");
}
if ($refresh) {
// generate list of possible suffixes
$units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($scope));
}
// print combobox with possible sub-DNs
listShowOUSelection($units, $suffix);
echo ("<input type=\"submit\" name=\"new\" value=\"" . _("New Group") . "\">\n");
if (sizeof($info) > 0) {
echo ("<input type=\"submit\" name=\"del\" value=\"" . _("Delete Group(s)") . "\">\n");
echo ("<br><br><br>\n");
echo "<fieldset><legend><b>PDF</b></legend>\n";
echo ("<b>" . _('PDF structure') . ":</b>&nbsp;&nbsp;<select name=\"pdf_structure\">\n");
$pdf_structures = getPDFStructureDefinitions($scope);
foreach($pdf_structures as $pdf_structure) {
echo "<option " . (($pdf_structure == 'default') ? " selected" : "") . ">" . $pdf_structure . "</option>";
}
echo "</select>&nbsp;&nbsp;&nbsp;&nbsp;\n";
echo ("<input type=\"submit\" name=\"pdf\" value=\"" . _("Create PDF for selected group(s)") . "\">\n");
echo "&nbsp;";
echo ("<input type=\"submit\" name=\"pdf_all\" value=\"" . _("Create PDF for all groups") . "\">\n");
echo "</fieldset>";
}
echo ("</form>\n");
echo "</body></html>\n";
// save variables to session
$_SESSION[$scope . '_units'] = $units;
$_SESSION[$scope . '_suffix'] = $suffix;
?>

View File

@ -1,246 +0,0 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2003 - 2004 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 detaexils.
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
*/
/**
* This page displays a list of all hosts.
*
* @package lists
* @author Roland Gruber
*/
/** Access to configuration options */
include_once ("../../lib/config.inc");
/** Access to LDAP connection */
include_once ("../../lib/ldap.inc");
/** Used to print status messages */
include_once ("../../lib/status.inc");
/** Used to create PDF files */
include_once("../../lib/pdf.inc");
/** Access to account modules */
include_once("../../lib/modules.inc");
/** Basic list functions */
include_once("../../lib/lists.inc");
// start session
session_save_path("../../sess");
@session_start();
setlanguage();
$scope = 'host';
// copy HTTP-GET variables to HTTP-POST
$_POST = $_POST + $_GET;
if (isset($_SESSION[$scope . 'info'])) $info = $_SESSION[$scope . 'info'];
if (isset($_SESSION[$scope . '_units'])) $units = $_SESSION[$scope . '_units'];
listDoPost($scope);
echo $_SESSION['header'];
echo "<title>listhosts</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
echo "</head><body>\n";
listPrintJavaScript();
// generate attribute-description table
$temp_array = listGetAttributeDescriptionList($scope);
$attr_array = array_keys($temp_array); // list of LDAP attributes to show
$desc_array = array_values($temp_array); // list of descriptions for the attributes
// get current page
if (isset($_GET["page"])) $page = $_GET["page"];
else $page = 1;
// take maximum count of host entries shown on one page out of session
if ($_SESSION["config"]->get_MaxListEntries() <= 0)
$max_page_entries = 10; // default setting, if not yet set
else
$max_page_entries = $_SESSION["config"]->get_MaxListEntries();
// get sorting column
if (isset($_GET["sort"])) $sort = $_GET["sort"];
else $sort = strtolower($attr_array[0]);
// check search suffix
if ($_POST['suffix']) $suffix = $_POST['suffix']; // new suffix selected via combobox
elseif ($_SESSION[$scope . '_suffix']) $suffix = $_SESSION[$scope . '_suffix']; // old suffix from session
else $suffix = $_SESSION["config"]->get_Suffix($scope); // default suffix
$refresh = true;
if (isset($_GET['norefresh'])) $refresh = false;
if (isset($_POST['refresh'])) $refresh = true;
if ($refresh) {
// configure search filter
$module_filter = get_ldap_filter("host"); // basic filter is provided by modules
$filter = "(&" . $module_filter . ")";
$attrs = $attr_array;
$sr = @ldap_search($_SESSION["ldap"]->server(), $suffix, $filter, $attrs);
if (ldap_errno($_SESSION["ldap"]->server()) == 4) {
StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem."));
}
if ($sr) {
$info = ldap_get_entries($_SESSION["ldap"]->server, $sr);
ldap_free_result($sr);
// delete first array entry which is "count"
unset($info['count']);
// save position in original $info
for ($i = 0; $i < sizeof($info); $i++) $info[$i]['LAM_ID'] = $i;
// save results
$_SESSION[$scope . 'info'] = $info;
}
else {
$info = array();
$_SESSION[$scope . 'info'] = array();
StatusMessage("ERROR", _("LDAP Search failed! Please check your preferences."), _("No hosts found!"));
}
}
$filter = listBuildFilter($attr_array);
$info = listFilterAccounts($info, $filter);
if (sizeof($info) == 0) StatusMessage("WARN", "", _("No hosts found!"));
// sort rows by sort column ($sort)
if ($info) {
$info = listSort($sort, $attr_array, $info);
}
// build filter URL
$searchFilter = array();
$filterAttributes = array_keys($filter);
for ($i = 0; $i < sizeof($filterAttributes); $i++) {
$searchFilter[] = "filter" . $filterAttributes[$i] . "=" . $filter[$filterAttributes[$i]]['original'];
}
if (sizeof($searchFilter) > 0) {
$searchFilter = "&amp;" . implode("&amp;", $searchFilter);
}
else {
$searchFilter = "";
}
echo ("<form action=\"listhosts.php?norefresh=true\" method=\"post\">\n");
// draw navigation bar if host accounts were found
if (sizeof($info) > 0) {
listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, $searchFilter, "host", _("%s host(s) found"));
echo ("<br>\n");
}
// account table head
listPrintTableHeader("host", $searchFilter, $desc_array, $attr_array, $_POST, $sort);
// calculate which rows to show
$table_begin = ($page - 1) * $max_page_entries;
if (($page * $max_page_entries) > sizeof($info)) $table_end = sizeof($info);
else $table_end = ($page * $max_page_entries);
if (sizeof($info) > 0) {
// print host list
for ($i = $table_begin; $i < $table_end; $i++) {
echo("<tr class=\"hostlist\" onMouseOver=\"list_over(this, '" . $info[$i]['LAM_ID'] . "', '" . $scope . "')\"\n" .
" onMouseOut=\"list_out(this, '" . $info[$i]['LAM_ID'] . "', '" . $scope . "')\"\n" .
" onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $scope . "')\"\n" .
" onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=host&amp;DN=" . $info[$i]['dn'] . "'\">\n");
if (isset($_GET['selectall'])) {
echo " <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $scope . "')\"" .
" type=\"checkbox\" checked name=\"" . $info[$i]['LAM_ID'] . "\"></td>\n";
}
else {
echo " <td height=22 align=\"center\"><input onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $scope . "')\"" .
" type=\"checkbox\" name=\"" . $info[$i]['LAM_ID'] . "\"></td>\n";
}
echo (" <td align='center'><a href=\"../account/edit.php?type=host&amp;DN='" . $info[$i]['dn'] . "'\">" . _("Edit") . "</a></td>\n");
for ($k = 0; $k < sizeof($attr_array); $k++) {
echo ("<td>");
// print all attribute entries seperated by "; "
$attrName = strtolower($attr_array[$k]);
if (isset($info[$i][$attrName]) && sizeof($info[$i][$attrName]) > 0) {
// delete "count" entry
unset($info[$i][$attrName]['count']);
if (is_array($info[$i][$attrName])) {
// sort array
sort($info[$i][$attrName]);
echo implode("; ", $info[$i][$attrName]);
}
else echo $info[$i][$attrName];
}
echo ("</td>\n");
}
echo("</tr>\n");
}
// display select all link
$colspan = sizeof($attr_array) + 1;
echo "<tr class=\"hostlist\">\n";
echo "<td align=\"center\"><img src=\"../../graphics/select.png\" alt=\"select all\"></td>\n";
echo "<td colspan=$colspan>&nbsp;<a href=\"listhosts.php?norefresh=y&amp;page=" . $page . "&amp;sort=" . $sort .
$searchFilter . "&amp;selectall=yes\">" .
"<font color=\"black\"><b>" . _("Select all") . "</b></font></a></td>\n";
echo "</tr>\n";
}
echo ("</table>");
echo ("<br>");
// draw navigation bar if host accounts were found
if (sizeof($info) > 0) {
listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort, $searchFilter, "host", _("%s host(s) found"));
echo ("<br>\n");
}
if ($refresh) {
// generate list of possible suffixes
$units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($scope));
}
// print combobox with possible sub-DNs
listShowOUSelection($units, $suffix);
// add/delete/PDF buttons
echo ("<input type=\"submit\" name=\"new\" value=\"" . _("New Host") . "\">\n");
if (sizeof($info) > 0) {
echo ("<input type=\"submit\" name=\"del\" value=\"" . _("Delete Host(s)") . "\">\n");
echo ("<br><br><br>\n");
echo "<fieldset><legend><b>PDF</b></legend>\n";
echo ("<b>" . _('PDF structure') . ":</b>&nbsp;&nbsp;<select name=\"pdf_structure\">\n");
$pdf_structures = getPDFStructureDefinitions($scope);
foreach($pdf_structures as $pdf_structure) {
echo "<option " . (($pdf_structure == 'default') ? " selected" : "") . ">" . $pdf_structure . "</option>";
}
echo "</select>&nbsp;&nbsp;&nbsp;&nbsp;\n";
echo ("<input type=\"submit\" name=\"pdf\" value=\"" . _("Create PDF for selected host(s)") . "\">\n");
echo "&nbsp;";
echo ("<input type=\"submit\" name=\"pdf_all\" value=\"" . _("Create PDF for all hosts") . "\">\n");
echo "</fieldset>";
}
echo ("</form>\n");
echo "</body></html>\n";
// save variables to session
$_SESSION[$scope . '_units'] = $units;
$_SESSION[$scope . '_suffix'] = $suffix;
?>

View File

@ -1,309 +0,0 @@
<?php
/*
$Id$
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2003 Roland Gruber, Leonhard Walchshäusl
Copyright (C) 2004 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 detaexils.
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
*/
/**
* This page displays a list of all users.
*
* @package lists
* @author Roland Gruber
*/
/** Access to configuration options */
include_once ("../../lib/config.inc");
/** Access to LDAP connection */
include_once ("../../lib/ldap.inc");
/** Used to print status messages */
include_once ("../../lib/status.inc");
/** Used to create PDF files */
include_once("../../lib/pdf.inc");
/** Access to account modules */
include_once("../../lib/modules.inc");
/** Basic list functions */
include_once("../../lib/lists.inc");
// start session
session_save_path("../../sess");
@session_start();
setlanguage();
$scope = 'user';
// copy HTTP-GET variables to HTTP-POST
$_POST = $_POST + $_GET;
$refresh = true;
if (isset($_GET['norefresh'])) $refresh = false;
if (isset($_POST['refresh'])) $refresh = true;
// check if primary group should be translated
if (isset($_POST['trans_primary']) && ($_POST['trans_primary'] == 'on')) $trans_primary = "on";
else $trans_primary = "off";
if (isset($_SESSION['trans_primary_hash'])) $trans_primary_hash = $_SESSION['trans_primary_hash'];
else $trans_primary_hash = array();
// generate hash table for group translation
if ($trans_primary == "on" && ($refresh || (sizeof($trans_primary_hash) == 0))) {
$trans_primary_hash = array();
$grp_suffix = $_SESSION['config']->get_Suffix('group');
$filter = "objectClass=posixGroup";
$attrs = array("cn", "gidNumber");
$sr = @ldap_search($_SESSION["ldap"]->server(), $grp_suffix, $filter, $attrs);
if ($sr) {
$info = @ldap_get_entries($_SESSION["ldap"]->server(), $sr);
unset($info['count']); // delete count entry
for ($i = 0; $i < sizeof($info); $i++) {
$trans_primary_hash[$info[$i]['gidnumber'][0]] = $info[$i]['cn'][0];
}
$_SESSION['trans_primary_hash'] = $trans_primary_hash;
}
}
if (isset($_SESSION[$scope . 'info'])) $info = $_SESSION[$scope . 'info'];
if (isset($_SESSION[$scope . '_units'])) $units = $_SESSION[$scope . '_units'];
listDoPost($scope);
echo $_SESSION['header'];
echo "<title>listusers</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
echo "</head><body>\n";
listPrintJavaScript();
// get current page
if (isset($_GET["page"])) $page = $_GET["page"];
else $page = 1;
// take maximum count of user entries shown on one page out of session
if ($_SESSION["config"]->get_MaxListEntries() <= 0) {
$max_page_entries = 10; // default setting, if not yet set
}
else $max_page_entries = $_SESSION["config"]->get_MaxListEntries();
// generate attribute-description table
$temp_array = listGetAttributeDescriptionList($scope);
$attr_array = array_keys($temp_array); // list of LDAP attributes to show
$desc_array = array_values($temp_array); // list of descriptions for the attributes
if (isset($_GET["sort"])) $sort = $_GET["sort"];
else $sort = strtolower($attr_array[0]);
// check search suffix
if (isset($_POST['suffix'])) $suffix = $_POST['suffix']; // new suffix selected via combobox
elseif (isset($_SESSION[$scope . '_suffix'])) $suffix = $_SESSION[$scope . '_suffix']; // old suffix from session
else $suffix = $_SESSION["config"]->get_Suffix($scope); // default suffix
// configure search filter for LDAP
$module_filter = get_ldap_filter($scope); // basic filter is provided by modules
$filter = "(&" . $module_filter . ")";
if ($refresh) {
$attrs = $attr_array;
$sr = @ldap_search($_SESSION["ldap"]->server(), $suffix, $filter, $attrs);
if (ldap_errno($_SESSION["ldap"]->server()) == 4) {
StatusMessage("WARN", _("LDAP sizelimit exceeded, not all entries are shown."), _("See README.openldap.txt to solve this problem."));
}
if ($sr) {
$info = ldap_get_entries ($_SESSION["ldap"]->server, $sr);
ldap_free_result ($sr);
// delete first array entry which is "count"
unset($info['count']);
// save position in original $info
for ($i = 0; $i < sizeof($info); $i++) $info[$i]['LAM_ID'] = $i;
// save results
$_SESSION[$scope . 'info'] = $info;
}
else {
$_SESSION[$scope . 'info'] = array();
$info = array();
StatusMessage("ERROR",
_("LDAP Search failed! Please check your preferences."),
_("No users found!"));
}
}
$filter = listBuildFilter($attr_array);
$info = listFilterAccounts($info, $filter);
if (sizeof($info) == 0) StatusMessage("WARN", "", _("No users found!"));
// sort rows by sort column ($sort)
if ($info) {
$info = listSort($sort, $attr_array, $info);
}
// build filter URL
$searchFilter = array();
$filterAttributes = array_keys($filter);
for ($i = 0; $i < sizeof($filterAttributes); $i++) {
$searchFilter[] = "filter" . $filterAttributes[$i] . "=" . $filter[$filterAttributes[$i]]['original'];
}
if (sizeof($searchFilter) > 0) {
$searchFilter = "&amp;" . implode("&amp;", $searchFilter);
}
else {
$searchFilter = "";
}
echo ("<form action=\"listusers.php?norefresh=true\" method=\"post\">\n");
// display table only if users exist in LDAP
if (sizeof($info) != 0) {
// create navigation bar on top of user table
listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort,
$searchFilter . "&amp;trans_primary=" . $trans_primary, $scope, _("%s user(s) found"));
echo ("<br />");
}
// account table head
listPrintTableHeader($scope, $searchFilter . "&amp;trans_primary=" . $trans_primary, $desc_array, $attr_array, $_POST, $sort);
// calculate which rows to show
$table_begin = ($page - 1) * $max_page_entries;
if (($page * $max_page_entries) > sizeof($info)) $table_end = sizeof($info);
else $table_end = ($page * $max_page_entries);
if (sizeof($info) != 0) {
// translate GIDs and resort array if selected
if ($trans_primary == "on") {
// translate GIDs
for ($i = 0; $i < sizeof($info); $i++) {
if (isset($trans_primary_hash[$info[$i]['gidnumber'][0]])) {
$info[$i]['gidnumber'][0] = $trans_primary_hash[$info[$i]['gidnumber'][0]];
}
}
// resort if needed
if ($sort == "gidnumber") {
$info = listSort($sort, $attr_array, $info);
}
}
// print user list
for ($i = $table_begin; $i < $table_end; $i++) {
echo("<tr class=\"userlist\"\nonMouseOver=\"list_over(this, '" . $info[$i]['LAM_ID'] . "', '" . $scope . "')\"\n" .
"onMouseOut=\"list_out(this, '" . $info[$i]['LAM_ID'] . "', '" . $scope . "')\"\n" .
"onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $scope . "')\"\n" .
"onDblClick=\"parent.frames[1].location.href='../account/edit.php?type=user&amp;DN=" . $info[$i]['dn'] . "'\">\n");
// checkboxes if selectall = "yes"
if (isset($_GET['selectall'])) {
echo "<td height=22 align=\"center\">\n<input onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $scope . "')\" type=\"checkbox\" name=\"" .
$info[$i]['LAM_ID'] . "\" checked>\n</td>\n";
}
else {
echo "<td height=22 align=\"center\">\n<input onClick=\"list_click(this, '" . $info[$i]['LAM_ID'] . "', '" . $scope . "')\" type=\"checkbox\" name=\"" .
$info[$i]['LAM_ID'] . "\">\n</td>\n";
}
echo ("<td align='center'>\n<a href=\"../account/edit.php?type=user&amp;DN='" . $info[$i]['dn'] . "'\">" .
_("Edit") . "</a>\n</td>\n");
for ($k = 0; $k < sizeof($attr_array); $k++) {
echo ("<td>\n");
// print attribute values
$attrName = strtolower($attr_array[$k]);
if (isset($info[$i][$attrName]) && sizeof($info[$i][$attrName]) > 0) {
if (is_array($info[$i][$attrName])) {
// delete first array entry which is "count"
unset($info[$i][$attrName]['count']);
// sort array
sort($info[$i][$attrName]);
// print all attribute entries seperated by "; "
echo implode("; ", $info[$i][$attrName]) . "\n";
}
else echo $info[$i][$attrName] . "\n";
}
echo ("</td>\n");
}
echo("</tr>\n");
}
// display select all link
$colspan = sizeof($attr_array) + 1;
echo "<tr class=\"userlist\">\n";
echo "<td align=\"center\"><img src=\"../../graphics/select.png\" alt=\"select all\"></td>\n";
echo "<td colspan=$colspan>&nbsp;<a href=\"listusers.php?norefresh=1&amp;page=" . $page . "&amp;sort=" . $sort .
$searchFilter . "&amp;trans_primary=" . $trans_primary . "&amp;selectall=yes\">" .
"<font color=\"black\"><b>" . _("Select all") . "</b></font></a></td>\n";
echo "</tr>\n";
}
echo ("</table>\n");
echo ("<br>");
if (sizeof($info) != 0) {
listDrawNavigationBar(sizeof($info), $max_page_entries, $page, $sort,
$searchFilter . "&amp;trans_primary=" . $trans_primary, $scope, _("%s user(s) found"));
echo ("<br>");
}
if ($refresh) {
// generate list of possible suffixes
$units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($scope));
}
// print combobox with possible sub-DNs
listShowOUSelection($units, $suffix);
// show translate GID to group name box if there is a column with gidnumber
if (in_array("gidnumber", $attr_array)) {
echo "<p align=\"left\">\n";
echo "<b>" . _("Translate GID number to group name") . ": </b>";
if ($trans_primary == "on") {
echo "<input type=\"checkbox\" name=\"trans_primary\" checked>";
}
else echo "<input type=\"checkbox\" name=\"trans_primary\">";
echo ("&nbsp;&nbsp;<input type=\"submit\" name=\"apply\" value=\"" . _("Apply") . "\">");
echo "</p>\n";
}
echo ("<p>&nbsp;</p>\n");
// new/delete/PDF buttons
echo ("<input type=\"submit\" name=\"new\" value=\"" . _("New user") . "\">\n");
if (sizeof($info) != 0) {
echo ("<input type=\"submit\" name=\"del\" value=\"" . _("Delete user(s)") . "\">\n");
echo ("<br><br><br>\n");
echo "<fieldset><legend><b>PDF</b></legend>\n";
echo ("<b>" . _('PDF structure') . ":</b>&nbsp;&nbsp;<select name=\"pdf_structure\">\n");
$pdf_structures = getPDFStructureDefinitions($scope);
foreach($pdf_structures as $pdf_structure) {
echo "<option " . (($pdf_structure == 'default') ? " selected" : "") . ">" . $pdf_structure . "</option>";
}
echo "</select>&nbsp;&nbsp;&nbsp;&nbsp;\n";
echo ("<input type=\"submit\" name=\"pdf\" value=\"" . _("Create PDF for selected user(s)") . "\">\n");
echo "&nbsp;";
echo ("<input type=\"submit\" name=\"pdf_all\" value=\"" . _("Create PDF for all users") . "\">\n");
echo "</fieldset>";
}
echo ("<p>&nbsp;</p>\n");
echo ("</form>\n");
echo "</body></html>\n";
// save variables to session
$_SESSION[$scope . '_units'] = $units;
$_SESSION[$scope . '_suffix'] = $suffix;
?>

View File

@ -62,7 +62,7 @@ else {
echo "</head><body>\n"; echo "</head><body>\n";
StatusMessage("ERROR", "", _("This user was not found!") . " (" . $user . ")"); StatusMessage("ERROR", "", _("This user was not found!") . " (" . $user . ")");
echo "<p>&nbsp;</p>"; echo "<p>&nbsp;</p>";
echo "<p><a href=\"listgroups.php\">" . _("Back to group list") . "</a></p>"; echo "<p><a href=\"list.php?type=group\">" . _("Back to group list") . "</a></p>";
echo ("</body></html>\n"); echo ("</body></html>\n");
} }

View File

@ -36,37 +36,15 @@ if (!isset($_SESSION['cache'])) {
$_SESSION['cache'] = new cache(); $_SESSION['cache'] = new cache();
} }
$startPage = "";
// check if all suffixes in conf-file exist // check if all suffixes in conf-file exist
$conf = $_SESSION['config']; $conf = $_SESSION['config'];
$new_suffs = array(); $new_suffs = array();
if ($conf->get_Suffix('user') && ($conf->get_Suffix('user') != "")) { // get list of active types
$startPage = "./lists/listusers.php"; $types = $_SESSION['config']->get_ActiveTypes();
$info = @ldap_search($_SESSION['ldap']->server, $conf->get_Suffix('user'), "", array()); for ($i = 0; $i < sizeof($types); $i++) {
$info = @ldap_search($_SESSION['ldap']->server, $conf->get_Suffix($types[$i]), "(objectClass=*)", array());
$res = @ldap_get_entries($_SESSION['ldap']->server, $info); $res = @ldap_get_entries($_SESSION['ldap']->server, $info);
if (!$res && !in_array($conf->get_Suffix('user'), $new_suffs)) $new_suffs[] = $conf->get_Suffix('user'); if (!$res && !in_array($conf->get_Suffix($types[$i]), $new_suffs)) $new_suffs[] = $conf->get_Suffix($types[$i]);
}
if ($conf->get_Suffix('group') && ($conf->get_Suffix('group') != "")) {
if ($startPage == "") {
$startPage = "./lists/listgroups.php";
}
$info = @ldap_search($_SESSION['ldap']->server, $conf->get_Suffix('group'), "", array());
$res = @ldap_get_entries($_SESSION['ldap']->server, $info);
if (!$res && !in_array($conf->get_Suffix('group'), $new_suffs)) $new_suffs[] = $conf->get_Suffix('group');
}
if ($conf->get_Suffix('host') && ($conf->get_Suffix('host') != "")) {
if ($startPage == "") {
$startPage = "./lists/listhosts.php";
}
$info = @ldap_search($_SESSION['ldap']->server, $conf->get_Suffix('host'), "", array());
$res = @ldap_get_entries($_SESSION['ldap']->server, $info);
if (!$res && !in_array($conf->get_Suffix('host'), $new_suffs)) $new_suffs[] = $conf->get_Suffix('host');
}
if ($conf->get_Suffix('domain') && ($conf->get_Suffix('domain') != "")) {
$info = @ldap_search($_SESSION['ldap']->server, $conf->get_Suffix('domain'), "", array());
$res = @ldap_get_entries($_SESSION['ldap']->server, $info);
if (!$res && !in_array($conf->get_Suffix('domain'), $new_suffs)) $new_suffs[] = $conf->get_Suffix('domain');
} }
// get encoding // get encoding
@ -88,7 +66,14 @@ echo ("<frame src=\"./main_header.php\" name=\"head\" frameborder=\"0\" scrollin
// display page to add suffixes, if needed // display page to add suffixes, if needed
if (sizeof($new_suffs) > 0) echo ("<frame src=\"initsuff.php?suffs='" . implode(";", $new_suffs) . if (sizeof($new_suffs) > 0) echo ("<frame src=\"initsuff.php?suffs='" . implode(";", $new_suffs) .
"'\" name=\"mainpart\" frameborder=\"0\" scrolling=\"yes\">\n"); "'\" name=\"mainpart\" frameborder=\"0\" scrolling=\"yes\">\n");
else echo ("<frame src=\"$startPage\" name=\"mainpart\" frameborder=\"0\" scrolling=\"yes\">\n"); else {
if (sizeof($types) > 0) {
echo ("<frame src=\"./lists/list.php?type=" . $types[0] . "\" name=\"mainpart\" frameborder=\"0\" scrolling=\"yes\">\n");
}
else {
echo ("<frame src=\"./tree/tree_view.php\" name=\"mainpart\" frameborder=\"0\" scrolling=\"yes\">\n");
}
}
echo ("<noframes>\n"); echo ("<noframes>\n");
echo ("This page requires a browser that can show frames!\n"); echo ("This page requires a browser that can show frames!\n");
echo ("</noframes>\n"); echo ("</noframes>\n");

View File

@ -40,10 +40,8 @@ setlanguage();
echo $_SESSION['header']; echo $_SESSION['header'];
// number of list views (users, groups, ...) // number of list views (users, groups, ...)
$lists = 0; $types = $_SESSION['config']->get_ActiveTypes();
if ($_SESSION['config']->get_Suffix('user') != "") $lists++; $lists = sizeof($types);
if ($_SESSION['config']->get_Suffix('group') != "") $lists++;
if ($_SESSION['config']->get_Suffix('host') != "") $lists++;
if ($_SESSION['config']->get_Suffix('tree') != "") $lists++; if ($_SESSION['config']->get_Suffix('tree') != "") $lists++;
?> ?>
@ -63,7 +61,7 @@ if ($_SESSION['config']->get_Suffix('tree') != "") $lists++;
<?php <?php
echo "<td colspan=$lists align=\"center\">\n"; echo "<td colspan=$lists align=\"center\">\n";
?> ?>
<a href="http://lam.sf.net" target="new_window"><img src="../graphics/banner.jpg" border=1 alt="LDAP Account Manager"></a> <a href="http://lam.sourceforge.net" target="new_window"><img src="../graphics/banner.jpg" border=1 alt="LDAP Account Manager"></a>
</td> </td>
<td width="200" align="right" height=20><img src="../graphics/go.png">&nbsp;<a href="./logout.php" target="_top"><big><b><?php echo _("Logout") ?></b></big></a></td> <td width="200" align="right" height=20><img src="../graphics/go.png">&nbsp;<a href="./logout.php" target="_top"><big><b><?php echo _("Logout") ?></b></big></a></td>
</tr> </tr>
@ -79,14 +77,11 @@ if ($_SESSION['config']->get_Suffix('tree') != "") $lists++;
if ($_SESSION['config']->get_Suffix('tree') != "") { if ($_SESSION['config']->get_Suffix('tree') != "") {
echo '<td width="120" align="center"><img src="../graphics/process.png">&nbsp;<a href="./tree/tree_view.php" target="mainpart"><big>' . _("Tree view") . '</big></a></td>' . "\n"; echo '<td width="120" align="center"><img src="../graphics/process.png">&nbsp;<a href="./tree/tree_view.php" target="mainpart"><big>' . _("Tree view") . '</big></a></td>' . "\n";
} }
if ($_SESSION['config']->get_Suffix('user') != "") { for ($i = 0; $i < sizeof($types); $i++) {
echo '<td width="120" align="center"><img src="../graphics/user.png">&nbsp;<a href="./lists/listusers.php" target="mainpart"><big>' . _("Users") . '</big></a></td>' . "\n"; echo '<td width="120" align="center">';
} echo '<img src="../graphics/' . $types[$i] . '.png">&nbsp;';
if ($_SESSION['config']->get_Suffix('group') != "") { echo '<a href="./lists/list.php?type=' . $types[$i] . '" target="mainpart"><big>' . getTypeAlias($types[$i]) . '</big></a>';
echo '<td width="120" align="center"><img src="../graphics/ou.png">&nbsp;<a href="./lists/listgroups.php" target="mainpart"><big>' . _("Groups") . '</big></a></td>' . "\n"; echo '</td>' . "\n";
}
if ($_SESSION['config']->get_Suffix('host') != "") {
echo '<td width="120" align="center"><img src="../graphics/host.png">&nbsp;<a href="./lists/listhosts.php" target="mainpart"><big>' . _("Hosts") . '</big></a></td>' . "\n";
} }
?> ?>
<td></td> <td></td>

View File

@ -63,16 +63,20 @@ if (isset($_GET['getCSV'])) {
exit; exit;
} }
$types = $_SESSION['config']->get_ActiveTypes();
echo $_SESSION['header']; echo $_SESSION['header'];
echo "<title>account upload</title>\n"; echo "<title>account upload</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\">\n"; echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\">\n";
for ($i = 0; $i < sizeof($types); $i++) {
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../style/type_" . $types[$i] . ".css\">\n";
}
echo "</head>\n"; echo "</head>\n";
echo "<body>\n"; echo "<body>\n";
// check if account specific page should be shown // check if account specific page should be shown
if (isset($_POST['user'])) showMainPage('user'); if (isset($_POST['type'])) showMainPage($_POST['type']);
elseif (isset($_POST['group'])) showMainPage('group');
elseif (isset($_POST['host'])) showMainPage('host');
// show start page // show start page
else { else {
echo "<h1 align=\"center\">" . _("Account creation via file upload") . "</h1>\n"; echo "<h1 align=\"center\">" . _("Account creation via file upload") . "</h1>\n";
@ -91,18 +95,15 @@ else {
echo "<form enctype=\"multipart/form-data\" action=\"masscreate.php\" method=\"post\">\n"; echo "<form enctype=\"multipart/form-data\" action=\"masscreate.php\" method=\"post\">\n";
echo "<table style=\"border-color: grey\" cellpadding=\"10\" border=\"2\" cellspacing=\"0\">\n"; echo "<table style=\"border-color: grey\" cellpadding=\"10\" border=\"2\" cellspacing=\"0\">\n";
for ($i = 0; $i < sizeof($types); $i++) {
echo "<tr>\n"; echo "<tr>\n";
echo "<th class=\"userlist-sort\">\n"; echo "<th class=\"" . $types[$i] . "list-sort\" align=\"center\"><input type=\"radio\" name=\"type\" value=\"" . $types[$i] . "\"></th>\n";
echo "<input type=\"submit\" name=\"user\" value=\"" . _("Create user accounts") . "\">\n"; echo "<th class=\"" . $types[$i] . "list-sort\" align=\"left\">" . getTypeAlias($types[$i]) . "</th>\n";
echo "</th>\n";
echo "<th class=\"grouplist-sort\">\n";
echo "<input type=\"submit\" name=\"group\" value=\"" . _("Create group accounts") . "\">\n";
echo "</th>\n";
echo "<th class=\"hostlist-sort\">\n";
echo "<input type=\"submit\" name=\"host\" value=\"" . _("Create host accounts") . "\">\n";
echo "</th>\n";
echo "</tr>\n"; echo "</tr>\n";
}
echo "</table>\n"; echo "</table>\n";
echo "<br><br>\n";
echo "<input type=\"submit\" name=\"submit\" value=\"". _("Submit") . "\">\n";
echo "</form>\n"; echo "</form>\n";
echo "</body>\n"; echo "</body>\n";
@ -161,7 +162,6 @@ function showMainPage($scope) {
echo "<ul>\n"; echo "<ul>\n";
echo "<li><b>" . _("Identifier") . ":</b> " . "dn_rdn</li>\n"; echo "<li><b>" . _("Identifier") . ":</b> " . "dn_rdn</li>\n";
echo "<li><b>" . _("Possible values") . ":</b> " . implode(", ", getRDNAttributes($scope)) . "</li>\n"; echo "<li><b>" . _("Possible values") . ":</b> " . implode(", ", getRDNAttributes($scope)) . "</li>\n";
echo "<li><b>" . _("Example value") . ":</b> " . "uid</li>\n";
echo "</ul>\n"; echo "</ul>\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";

View File

@ -41,20 +41,23 @@ session_save_path("../sess");
setlanguage(); setlanguage();
$types = $_SESSION['config']->get_ActiveTypes();
// check if submit button was pressed // check if submit button was pressed
if ($_POST['submit']) { if ($_POST['submit']) {
// user operations // check user input
// new user ou for ($i = 0; $i < sizeof($types); $i++) {
if ($_POST['type'] == "new_usr") { // new ou
if ($_POST['type'] == "new_" . $types[$i]) {
// create ou if valid // create ou if valid
if (eregi("^[a-z0-9 _\\-]+$", $_POST['newsuff_u'])) { if (eregi("^[a-z0-9 _\\-]+$", $_POST['newname_' . $types[$i]])) {
// check if ou already exists // check if ou already exists
$new_dn = "ou=" . $_POST['newsuff_u'] . "," . $_POST['usersuff_n']; $new_dn = "ou=" . $_POST['newname_' . $types[$i]] . "," . $_POST['parentsuff_' . $types[$i]];
if (!in_array(strtolower($new_dn), $_SESSION['ldap']->search_units($_POST['usersuff_n']))) { if (!in_array($new_dn, $_SESSION['ldap']->search_units($_POST['parentsuff_' . $types[$i]]))) {
// add new ou // add new ou
$ou = array(); $ou = array();
$ou['objectClass'] = "organizationalunit"; $ou['objectClass'] = "organizationalunit";
$ou['ou'] = $_POST['newsuff_u']; $ou['ou'] = $_POST['newname_' . $types[$i]];
$ret = @ldap_add($_SESSION['ldap']->server(), $new_dn, $ou); $ret = @ldap_add($_SESSION['ldap']->server(), $new_dn, $ou);
if ($ret) { if ($ret) {
$message = _("New OU created successfully."); $message = _("New OU created successfully.");
@ -67,12 +70,12 @@ if ($_POST['submit']) {
} }
// show errormessage if ou is invalid // show errormessage if ou is invalid
else { else {
$error = _("OU is invalid!") . " " . $_POST['newsuff_u']; $error = _("OU is invalid!") . " " . $_POST['newname_' . $types[$i]];
} }
} }
// delete ou, user was sure // delete ou, user was sure
elseif (($_POST['type'] == "del_usr") && ($_POST['sure'])) { elseif (($_POST['type'] == "del_" . $types[$i]) && ($_POST['sure'])) {
$ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['usersuff_d']); $ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['deletename_' . $types[$i]]);
if ($ret) { if ($ret) {
$message = _("OU deleted successfully."); $message = _("OU deleted successfully.");
} }
@ -81,24 +84,24 @@ if ($_POST['submit']) {
} }
} }
// do not delete ou // do not delete ou
elseif (($_POST['type'] == "del_usr") && ($_POST['abort'])) { elseif (($_POST['type'] == "del_" . $types[$i]) && ($_POST['abort'])) {
display_main(); display_main();
exit; exit;
} }
// ask if user is sure to delete // ask if user is sure to delete
elseif ($_POST['type'] == "del_usr") { elseif ($_POST['type'] == "del_" . $types[$i]) {
// check for sub entries // check for sub entries
$sr = @ldap_list($_SESSION['ldap']->server(), $_POST['usersuff_d'], "ObjectClass=*", array("")); $sr = @ldap_list($_SESSION['ldap']->server(), $_POST['deletename_' . $types[$i]], "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) {
$text = "<br>\n" . $text = "<br>\n" .
"<p><big><b>" . _("Do you really want to delete this OU?") . " </b></big>" . "\n" . "<p><big><b>" . _("Do you really want to delete this OU?") . " </b></big>" . "\n" .
"<br>\n<p>" . $_POST['usersuff_d'] . "</p>\n" . "<br>\n<p>" . $_POST['deletename_' . $types[$i]] . "</p>\n" .
"<br>\n" . "<br>\n" .
"<form action=\"ou_edit.php?type=user\" method=\"post\">\n" . "<form action=\"ou_edit.php\" method=\"post\">\n" .
"<input type=\"hidden\" name=\"type\" value=\"del_usr\">\n" . "<input type=\"hidden\" name=\"type\" value=\"del_" . $types[$i] . "\">\n" .
"<input type=\"hidden\" name=\"submit\" value=\"submit\">\n" . "<input type=\"hidden\" name=\"submit\" value=\"submit\">\n" .
"<input type=\"hidden\" name=\"usersuff_d\" value=\"" . $_POST['usersuff_d'] . "\">\n" . "<input type=\"hidden\" name=\"deletename_" . $types[$i] . "\" value=\"" . $_POST['deletename_' . $types[$i]] . "\">\n" .
"<input type=\"submit\" name=\"sure\" value=\"" . _("Submit") . "\">\n" . "<input type=\"submit\" name=\"sure\" value=\"" . _("Submit") . "\">\n" .
"<input type=\"submit\" name=\"abort\" value=\"" . _("Abort") . "\">\n" . "<input type=\"submit\" name=\"abort\" value=\"" . _("Abort") . "\">\n" .
"</form>"; "</form>";
@ -107,201 +110,8 @@ if ($_POST['submit']) {
$error = _("OU is not empty or invalid!"); $error = _("OU is not empty or invalid!");
} }
} }
}
// group operations
// new group ou
if ($_POST['type'] == "new_grp") {
// create ou if valid
if (eregi("^[a-z0-9 _\\-]+$", $_POST['newsuff_g'])) {
// check if ou already exists
$new_dn = "ou=" . $_POST['newsuff_g'] . "," . $_POST['groupsuff_n'];
if (!in_array(strtolower($new_dn), $_SESSION['ldap']->search_units($_POST['groupsuff_n']))) {
// add new ou
$ou = array();
$ou['objectClass'] = "organizationalunit";
$ou['ou'] = $_POST['newsuff_g'];
$ret = @ldap_add($_SESSION['ldap']->server(), $new_dn, $ou);
if ($ret) {
$message = _("New OU created successfully.");
}
else {
$error = _("Unable to create new OU!");
}
}
else $error = _("OU already exists!");
}
// show errormessage if ou is invalid
else {
$error = _("OU is invalid!") . " " . $_POST['newsuff_g'];
}
}
// delete ou, user was sure
elseif (($_POST['type'] == "del_grp") && ($_POST['sure'])) {
$ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['groupsuff_d']);
if ($ret) {
$message = _("OU deleted successfully.");
}
else {
$error = _("Unable to delete OU!");
}
}
// do not delete ou
elseif (($_POST['type'] == "del_grp") && ($_POST['abort'])) {
display_main();
exit;
}
// ask if user is sure to delete
elseif ($_POST['type'] == "del_grp") {
// check for sub entries
$sr = @ldap_list($_SESSION['ldap']->server(), $_POST['groupsuff_d'], "ObjectClass=*", array(""));
$info = @ldap_get_entries($_SESSION['ldap']->server(), $sr);
if ($sr && $info['count'] == 0) {
$text = "<br>\n" .
"<p><big><b>" . _("Do you really want to delete this OU?") . " </b></big>" . "\n" .
"<br>\n<p>" . $_POST['groupsuff_d'] . "</p>\n" .
"<br>\n" .
"<form action=\"ou_edit.php?type=group\" method=\"post\">\n" .
"<input type=\"hidden\" name=\"type\" value=\"del_grp\">\n" .
"<input type=\"hidden\" name=\"submit\" value=\"submit\">\n" .
"<input type=\"hidden\" name=\"groupsuff_d\" value=\"" . $_POST['groupsuff_d'] . "\">\n" .
"<input type=\"submit\" name=\"sure\" value=\"" . _("Submit") . "\">\n" .
"<input type=\"submit\" name=\"abort\" value=\"" . _("Abort") . "\">\n" .
"</form>";
}
else {
$error = _("OU is not empty or invalid!");
}
}
// host operations
// new host ou
if ($_POST['type'] == "new_hst") {
// create ou if valid
if (eregi("^[a-z0-9 _\\-]+$", $_POST['newsuff_h'])) {
// check if ou already exists
$new_dn = "ou=" . $_POST['newsuff_h'] . "," . $_POST['hostsuff_n'];
if (!in_array(strtolower($new_dn), $_SESSION['ldap']->search_units($_POST['hostsuff_n']))) {
// add new ou
$ou = array();
$ou['objectClass'] = "organizationalunit";
$ou['ou'] = $_POST['newsuff_h'];
$ret = @ldap_add($_SESSION['ldap']->server(), $new_dn, $ou);
if ($ret) {
$message = _("New OU created successfully.");
}
else {
$error = _("Unable to create new OU!");
}
}
else $error = _("OU already exists!");
}
// show errormessage if ou is invalid
else {
$error = _("OU is invalid!") . " " . $_POST['newsuff_h'];
}
}
// delete ou, user was sure
elseif (($_POST['type'] == "del_hst") && ($_POST['sure'])) {
$ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['hostsuff_d']);
if ($ret) {
$message = _("OU deleted successfully.");
}
else {
$error = _("Unable to delete OU!");
}
}
// do not delete ou
elseif (($_POST['type'] == "del_hst") && ($_POST['abort'])) {
display_main();
exit;
}
// ask if user is sure to delete
elseif ($_POST['type'] == "del_hst") {
// check for sub entries
$sr = @ldap_list($_SESSION['ldap']->server(), $_POST['hostsuff_d'], "ObjectClass=*", array(""));
$info = @ldap_get_entries($_SESSION['ldap']->server(), $sr);
if ($sr && $info['count'] == 0) {
$text = "<br>\n" .
"<p><big><b>" . _("Do you really want to delete this OU?") . " </b></big>" . "\n" .
"<br>\n<p>" . $_POST['hostsuff_d'] . "</p>\n" .
"<br>\n" .
"<form action=\"ou_edit.php?type=host\" method=\"post\">\n" .
"<input type=\"hidden\" name=\"type\" value=\"del_hst\">\n" .
"<input type=\"hidden\" name=\"submit\" value=\"submit\">\n" .
"<input type=\"hidden\" name=\"hostsuff_d\" value=\"" . $_POST['hostsuff_d'] . "\">\n" .
"<input type=\"submit\" name=\"sure\" value=\"" . _("Submit") . "\">\n" .
"<input type=\"submit\" name=\"abort\" value=\"" . _("Abort") . "\">\n" .
"</form>";
}
else {
$error = _("OU is not empty or invalid!");
}
}
// domain operations
// new domain ou
if ($_POST['type'] == "new_dom") {
// create ou if valid
if (eregi("^[a-z0-9 _\\-]+$", $_POST['newsuff_d'])) {
// check if ou already exists
$new_dn = "ou=" . $_POST['newsuff_d'] . "," . $_POST['domsuff_n'];
if (!in_array(strtolower($new_dn), $_SESSION['ldap']->search_units($_POST['domsuff_n']))) {
// add new ou
$ou = array();
$ou['objectClass'] = "organizationalunit";
$ou['ou'] = $_POST['newsuff_d'];
$ret = @ldap_add($_SESSION['ldap']->server(), $new_dn, $ou);
if ($ret) {
$message = _("New OU created successfully.");
}
else {
$error = _("Unable to create new OU!");
}
}
else $error = _("OU already exists!");
}
// show errormessage if ou is invalid
else {
$error = _("OU is invalid!") . " " . $_POST['newsuff_d'];
}
}
// delete ou, user was sure
elseif (($_POST['type'] == "del_dom") && ($_POST['sure'])) {
$ret = @ldap_delete($_SESSION['ldap']->server(), $_POST['domsuff_d']);
if ($ret) {
$message = _("OU deleted successfully.");
}
else {
$error = _("Unable to delete OU!");
}
}
// do not delete ou
elseif (($_POST['type'] == "del_dom") && ($_POST['abort'])) {
display_main();
exit;
}
// ask if user is sure to delete
elseif ($_POST['type'] == "del_dom") {
// check for sub entries
$sr = @ldap_list($_SESSION['ldap']->server(), $_POST['domsuff_d'], "ObjectClass=*", array(""));
$info = @ldap_get_entries($_SESSION['ldap']->server(), $sr);
if ($sr && $info['count'] == 0) {
$text = "<br>\n" .
"<p><big><b>" . _("Do you really want to delete this OU?") . " </b></big>" . "\n" .
"<br>\n<p>" . $_POST['domsuff_d'] . "</p>\n" .
"<br>\n" .
"<form action=\"ou_edit.php?type=host\" method=\"post\">\n" .
"<input type=\"hidden\" name=\"type\" value=\"del_dom\">\n" .
"<input type=\"hidden\" name=\"submit\" value=\"submit\">\n" .
"<input type=\"hidden\" name=\"domsuff_d\" value=\"" . $_POST['domsuff_d'] . "\">\n" .
"<input type=\"submit\" name=\"sure\" value=\"" . _("Submit") . "\">\n" .
"<input type=\"submit\" name=\"abort\" value=\"" . _("Abort") . "\">\n" .
"</form>";
}
else {
$error = _("OU is not empty or invalid!");
}
}
// print header // print header
echo $_SESSION['header']; echo $_SESSION['header'];
@ -328,153 +138,47 @@ exit;
else display_main(); else display_main();
function display_main() { function display_main() {
$types = $_SESSION['config']->get_ActiveTypes();
// display main page // display main page
echo $_SESSION['header']; echo $_SESSION['header'];
echo ("<title>OU-Editor</title>\n"); echo ("<title>OU-Editor</title>\n");
echo ("<link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\">\n"); echo ("<link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\">\n");
for ($i = 0; $i < sizeof($types); $i++) {
echo ("<link rel=\"stylesheet\" type=\"text/css\" href=\"../style/type_" . $types[$i] . ".css\">\n");
}
echo ("</head>\n"); echo ("</head>\n");
echo ("<body>\n"); echo ("<body>\n");
echo "<h1>" . _("OU editor") . "</h1>";
echo ("<br>\n"); echo ("<br>\n");
echo ("<form action=\"ou_edit.php?type=user\" method=\"post\">\n"); echo ("<form action=\"ou_edit.php\" method=\"post\">\n");
// user OUs // display fieldsets
if ($_SESSION["config"]->get_Suffix('user') != "") { for ($i = 0; $i < sizeof($types); $i++) {
// generate lists of possible suffixes // generate lists of possible suffixes
$usr_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix('user')); $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($types[$i]));
echo ("<fieldset><legend><b>" . _("Users") . "</b></legend>\n"); echo ("<fieldset class=\"" . $types[$i] . "edit\"><legend><b>" . getTypeAlias($types[$i]) . "</b></legend>\n");
echo ("<table border=0>\n"); echo ("<table border=0>\n");
// new OU // new OU
echo ("<tr>\n"); echo ("<tr>\n");
echo ("<td><input type=radio name=\"type\" value=\"new_usr\" checked></td>\n"); echo ("<td><input type=radio name=\"type\" value=\"new_" . $types[$i] . "\"></td>\n");
echo ("<td><b>" . _("New organizational unit") . ":</b></td>\n"); echo ("<td><b>" . _("New organizational unit") . ":</b></td>\n");
echo ("<td>&nbsp;</td>\n"); echo ("<td>&nbsp;</td>\n");
echo ("<td><select size=1 name=usersuff_n>"); echo ("<td><select size=1 name=parentsuff_" . $types[$i] . ">");
for ($i = 0; $i < sizeof($usr_units); $i++) { for ($u = 0; $u < sizeof($units); $u++) {
echo ("<option>" . $usr_units[$i] . "</option>\n"); echo ("<option>" . $units[$u] . "</option>\n");
} }
echo ("</select><td>\n"); echo ("</select><td>\n");
echo ("<td><input type=text name=newsuff_u></td>\n"); echo ("<td><input type=text name=newname_" . $types[$i] . "></td>\n");
echo ("<td><a href=\"help.php?HelpNumber=601\" target=\"lamhelp\">". _("Help") ."</a></td>\n"); echo ("<td><a href=\"help.php?HelpNumber=601\" target=\"lamhelp\">". _("Help") ."</a></td>\n");
echo ("</tr>\n"); echo ("</tr>\n");
// delete OU // delete OU
echo ("<tr>\n"); echo ("<tr>\n");
echo ("<td><input type=radio name=\"type\" value=\"del_usr\"></td>\n"); echo ("<td><input type=radio name=\"type\" value=\"del_" . $types[$i] . "\"></td>\n");
echo ("<td><b>" . _("Delete organizational unit") . ":</b></td>\n"); echo ("<td><b>" . _("Delete organizational unit") . ":</b></td>\n");
echo ("<td>&nbsp;</td>\n"); echo ("<td>&nbsp;</td>\n");
echo ("<td><select size=1 name=usersuff_d>"); echo ("<td><select size=1 name=deletename_" . $types[$i] . ">");
for ($i = 0; $i < sizeof($usr_units); $i++) { for ($u = 0; $u < sizeof($units); $u++) {
echo ("<option>" . $usr_units[$i] . "</option>\n"); echo ("<option>" . $units[$u] . "</option>\n");
}
echo ("</select><td>\n");
echo ("<td>&nbsp;</td>\n");
echo ("<td><a href=\"help.php?HelpNumber=602\" target=\"lamhelp\">". _("Help") ."</a></td>\n");
echo ("</tr>\n");
echo ("</table>\n");
echo ("</fieldset>\n");
echo ("<br>\n");
}
// group OUs
if ($_SESSION["config"]->get_Suffix('group') != "") {
// generate lists of possible suffixes
$grp_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix('group'));
echo ("<fieldset><legend><b>" . _("Groups") . "</b></legend>\n");
echo ("<table border=0>\n");
// new OU
echo ("<tr>\n");
echo ("<td><input type=radio name=\"type\" value=\"new_grp\"></td>\n");
echo ("<td><b>" . _("New organizational unit") . ":</b></td>\n");
echo ("<td>&nbsp;</td>\n");
echo ("<td><select size=1 name=groupsuff_n>");
for ($i = 0; $i < sizeof($grp_units); $i++) {
echo ("<option>" . $grp_units[$i] . "</option>\n");
}
echo ("</select><td>\n");
echo ("<td><input type=text name=newsuff_g></td>\n");
echo ("<td><a href=\"help.php?HelpNumber=601\" target=\"lamhelp\">". _("Help") ."</a></td>\n");
echo ("</tr>\n");
// delete OU
echo ("<tr>\n");
echo ("<td><input type=radio name=\"type\" value=\"del_grp\"></td>\n");
echo ("<td><b>" . _("Delete organizational unit") . ":</b></td>\n");
echo ("<td>&nbsp;</td>\n");
echo ("<td><select size=1 name=groupsuff_d>");
for ($i = 0; $i < sizeof($grp_units); $i++) {
echo ("<option>" . $grp_units[$i] . "</option>\n");
}
echo ("</select><td>\n");
echo ("<td>&nbsp;</td>\n");
echo ("<td><a href=\"help.php?HelpNumber=602\" target=\"lamhelp\">". _("Help") ."</a></td>\n");
echo ("</tr>\n");
echo ("</table>\n");
echo ("</fieldset>\n");
echo ("<br>\n");
}
// host OUs
if ($_SESSION["config"]->get_Suffix('host') != "") {
// generate lists of possible suffixes
$hst_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix('host'));
echo ("<fieldset><legend><b>" . _("Samba Hosts") . "</b></legend>\n");
echo ("<table border=0>\n");
// new OU
echo ("<tr>\n");
echo ("<td><input type=radio name=\"type\" value=\"new_hst\"></td>\n");
echo ("<td><b>" . _("New organizational unit") . ":</b></td>\n");
echo ("<td>&nbsp;</td>\n");
echo ("<td><select size=1 name=hostsuff_n>");
for ($i = 0; $i < sizeof($hst_units); $i++) {
echo ("<option>" . $hst_units[$i] . "</option>\n");
}
echo ("</select><td>\n");
echo ("<td><input type=text name=newsuff_h></td>\n");
echo ("<td><a href=\"help.php?HelpNumber=601\" target=\"lamhelp\">". _("Help") ."</a></td>\n");
echo ("</tr>\n");
// delete OU
echo ("<tr>\n");
echo ("<td><input type=radio name=\"type\" value=\"del_hst\"></td>\n");
echo ("<td><b>" . _("Delete organizational unit") . ":</b></td>\n");
echo ("<td>&nbsp;</td>\n");
echo ("<td><select size=1 name=hostsuff_d>");
for ($i = 0; $i < sizeof($hst_units); $i++) {
echo ("<option>" . $hst_units[$i] . "</option>\n");
}
echo ("</select><td>\n");
echo ("<td>&nbsp;</td>\n");
echo ("<td><a href=\"help.php?HelpNumber=602\" target=\"lamhelp\">". _("Help") ."</a></td>\n");
echo ("</tr>\n");
echo ("</table>\n");
echo ("</fieldset>\n");
echo ("<br>\n");
}
// domain OUs
if ($_SESSION["config"]->get_Suffix('domain') != "") {
// generate lists of possible suffixes
$dom_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix('domain'));
echo ("<fieldset><legend><b>" . _("Domains") . "</b></legend>\n");
echo ("<table border=0>\n");
// new OU
echo ("<tr>\n");
echo ("<td><input type=radio name=\"type\" value=\"new_dom\"></td>\n");
echo ("<td><b>" . _("New organizational unit") . ":</b></td>\n");
echo ("<td>&nbsp;</td>\n");
echo ("<td><select size=1 name=domsuff_n>");
for ($i = 0; $i < sizeof($dom_units); $i++) {
echo ("<option>" . $dom_units[$i] . "</option>\n");
}
echo ("</select><td>\n");
echo ("<td><input type=text name=newsuff_d></td>\n");
echo ("<td><a href=\"help.php?HelpNumber=601\" target=\"lamhelp\">". _("Help") ."</a></td>\n");
echo ("</tr>\n");
// delete OU
echo ("<tr>\n");
echo ("<td><input type=radio name=\"type\" value=\"del_dom\"></td>\n");
echo ("<td><b>" . _("Delete organizational unit") . ":</b></td>\n");
echo ("<td>&nbsp;</td>\n");
echo ("<td><select size=1 name=domsuff_d>");
for ($i = 0; $i < sizeof($dom_units); $i++) {
echo ("<option>" . $dom_units[$i] . "</option>\n");
} }
echo ("</select><td>\n"); echo ("</select><td>\n");
echo ("<td>&nbsp;</td>\n"); echo ("<td>&nbsp;</td>\n");

View File

@ -73,9 +73,18 @@ if ($_POST['abort']) {
// check if right type was given // check if right type was given
$type = $_GET['type']; $type = $_GET['type'];
if (($type == "user") || ($type == "host") || ($type == "group")) { echo ("<p align=\"center\"><big>" . _("Do you really want to delete this PDF structure?") . "</big>");
echo ("<p align=\"center\"><big>" . _("Do you really want to delete this PDF structure?") . " <b>"); echo "<br>\n";
echo (_('Scope') . ': ' . $_GET['type'] . ' ' . _('Name') . ': ' . $_GET['delete'] . "</b></big><br></p>\n"); echo "<br></p>\n";
echo "<table align=\"center\">\n";
echo "<tr><td>\n";
echo "<b>" . _('Account type') . ': </b>' . $_GET['type'];
echo "</td></tr>\n";
echo "<tr><td>\n";
echo "<b>" . _('Name') . ': </b>' . $_GET['delete'] . "<br>\n";
echo "</td></tr>\n";
echo "</table>\n";
echo "<br>\n";
echo ("<form action=\"pdfdelete.php\" method=\"post\">\n"); echo ("<form action=\"pdfdelete.php\" method=\"post\">\n");
echo ("<p align=\"center\">\n"); echo ("<p align=\"center\">\n");
echo ("<input type=\"submit\" name=\"submit\" value=\"" . _("Submit") . "\">\n"); echo ("<input type=\"submit\" name=\"submit\" value=\"" . _("Submit") . "\">\n");
@ -83,9 +92,3 @@ if (($type == "user") || ($type == "host") || ($type == "group")) {
echo ("<input type=\"hidden\" name=\"type\" value=\"" . $_GET['type'] . "\">"); echo ("<input type=\"hidden\" name=\"type\" value=\"" . $_GET['type'] . "\">");
echo ("<input type=\"hidden\" name=\"delete\" value=\"" . $_GET['delete'] . "\">"); echo ("<input type=\"hidden\" name=\"delete\" value=\"" . $_GET['delete'] . "\">");
echo ("</p></form></body></html>\n"); echo ("</p></form></body></html>\n");
}
else{
// no valid pdf type
StatusMessage("ERROR", "", _("Wrong or missing type!") . " " . $type);
echo ("<a href=\"pdfmain.php\">" . _("Back to PDF Editor") . "</a>");
}

View File

@ -82,7 +82,7 @@ if ($_POST['forward'] == "yes") {
exit; exit;
} }
$scopes = getAvailableScopes(); $scopes = $_SESSION['config']->get_ActiveTypes();
$availableStructureDefinitions = ''; $availableStructureDefinitions = '';
$availableScopes = ''; $availableScopes = '';

View File

@ -73,10 +73,7 @@ if ($_POST['abort']) {
exit; exit;
} }
// check if right type was given
$type = $_GET['type']; $type = $_GET['type'];
if (($type == "user") || ($type == "host") || ($type == "group")) {
// user profile
echo ("<p align=\"center\"><big>" . _("Do you really want to delete this profile?") . " <b>"); echo ("<p align=\"center\"><big>" . _("Do you really want to delete this profile?") . " <b>");
echo ($_GET['del'] . "</b></big><br></p>\n"); echo ($_GET['del'] . "</b></big><br></p>\n");
echo ("<form action=\"profiledelete.php\" method=\"post\">\n"); echo ("<form action=\"profiledelete.php\" method=\"post\">\n");
@ -86,9 +83,3 @@ if (($type == "user") || ($type == "host") || ($type == "group")) {
echo ("<input type=\"hidden\" name=\"type\" value=\"$type\">"); echo ("<input type=\"hidden\" name=\"type\" value=\"$type\">");
echo ("<input type=\"hidden\" name=\"del\" value=\"" . $_GET['del'] . "\">"); echo ("<input type=\"hidden\" name=\"del\" value=\"" . $_GET['del'] . "\">");
echo ("</p></form></body></html>\n"); echo ("</p></form></body></html>\n");
}
else{
// no valid profile type
StatusMessage("ERROR", "", _("Wrong or missing type!") . " " . $type);
echo ("<a href=\"profilemain.php\">" . _("Back to profile editor") . "</a>");
}

View File

@ -41,11 +41,15 @@ session_save_path("../../sess");
setlanguage(); setlanguage();
$profileClasses = array( $types = $_SESSION['config']->get_ActiveTypes();
array('scope' => 'user', 'title' => _('User profiles'), 'profiles' => ""), $profileClasses = array();
array('scope' => 'group', 'title' => _('Group profiles'), 'profiles' => ""), for ($i = 0; $i < sizeof($types); $i++) {
array('scope' => 'host', 'title' => _('Host profiles'), 'profiles' => "") $profileClasses[] = array(
); 'scope' => $types[$i],
'title' => getTypeAlias($types[$i]),
'profiles' => "");
}
// check if user is logged in, if not go to login // check if user is logged in, if not go to login
if (!$_SESSION['ldap'] || !$_SESSION['ldap']->server()) { if (!$_SESSION['ldap'] || !$_SESSION['ldap']->server()) {
@ -97,6 +101,9 @@ echo $_SESSION['header'];
echo "<title>LDAP Account Manager</title>\n"; echo "<title>LDAP Account Manager</title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n"; echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
for ($i = 0; $i < sizeof($profileClasses); $i++) {
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/type_" . $profileClasses[$i]['scope'] . ".css\">\n";
}
echo "</head>\n"; echo "</head>\n";
echo "<body>\n"; echo "<body>\n";
@ -106,7 +113,7 @@ echo "<form action=\"profilemain.php\" method=\"post\">\n";
for ($i = 0; $i < sizeof($profileClasses); $i++) { for ($i = 0; $i < sizeof($profileClasses); $i++) {
echo "<fieldset>\n"; echo "<fieldset class=\"" . $profileClasses[$i]['scope'] . "edit\">\n";
echo "<legend>\n"; echo "<legend>\n";
echo "<b>" . $profileClasses[$i]['title'] . "</b>\n"; echo "<b>" . $profileClasses[$i]['title'] . "</b>\n";
echo "</legend>\n"; echo "</legend>\n";

View File

@ -65,6 +65,7 @@ if ($_POST['abort']) {
// print header // print header
echo $_SESSION['header']; echo $_SESSION['header'];
echo "<title></title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n"; echo "<title></title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
echo "<title></title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/type_" . $_GET['type'] . ".css\">\n";
echo "</head><body><br>\n"; echo "</head><body><br>\n";
// save button was presed // save button was presed
@ -130,7 +131,6 @@ $_SESSION['profile_types'] = array();
// check if account type is valid // check if account type is valid
$type = $_GET['type']; $type = $_GET['type'];
if (!(($type == 'user') || ($type == 'group') || ($type == 'host'))) meta_refresh('profilemain.php');
// get module options // get module options
$options = getProfileOptions($type); $options = getProfileOptions($type);

View File

@ -42,6 +42,7 @@ echo $_SESSION['header'];
echo "<title></title>\n"; echo "<title></title>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\">\n"; echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\">\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../style/type_user.css\">\n";
echo "</head>"; echo "</head>";
echo "<body>\n"; echo "<body>\n";
@ -55,15 +56,6 @@ $tools[] = array(
"link" => "profedit/profilemain.php" "link" => "profedit/profilemain.php"
); );
// Samba 3 domains
if ($_SESSION['config']->get_Suffix('domain') && ($_SESSION['config']->get_Suffix('domain') != "")) {
$tools[] = array(
"name" => _("Samba 3 domains"),
"description" => _("Manages Samba 3 domain accounts."),
"link" => "lists/listdomains.php"
);
}
// file upload // file upload
$tools[] = array( $tools[] = array(
"name" => _("File upload"), "name" => _("File upload"),

View File

@ -34,8 +34,6 @@ include ("../lib/config.inc");
$conf = new Config('test'); $conf = new Config('test');
echo "<html><head><title></title><link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\"></head><body>"; echo "<html><head><title></title><link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\"></head><body>";
echo ("<b> Current Config</b><br><br>");
$conf->printconf();
echo ("<br><br><big><b> Starting Test...</b></big><br><br>"); echo ("<br><br><big><b> Starting Test...</b></big><br><br>");
// now all preferences are loaded // now all preferences are loaded
echo ("Loading preferences..."); echo ("Loading preferences...");
@ -46,7 +44,7 @@ $Adminstring = $conf->get_Adminstring();
$Suff_users = $conf->get_Suffix('user'); $Suff_users = $conf->get_Suffix('user');
$Suff_groups = $conf->get_Suffix('group'); $Suff_groups = $conf->get_Suffix('group');
$Suff_hosts = $conf->get_Suffix('host'); $Suff_hosts = $conf->get_Suffix('host');
$Suff_domains = $conf->get_Suffix('domain'); $Suff_domains = $conf->get_Suffix('smbDomain');
$userlistAttributes = $conf->get_listAttributes('user'); $userlistAttributes = $conf->get_listAttributes('user');
$grouplistAttributes = $conf->get_listAttributes('group'); $grouplistAttributes = $conf->get_listAttributes('group');
$hostlistAttributes = $conf->get_listAttributes('host'); $hostlistAttributes = $conf->get_listAttributes('host');
@ -65,7 +63,7 @@ $conf->set_Adminstring("uid=test,o=test,dc=org;uid=root,o=test2,c=de");
$conf->set_Suffix('user', "ou=test,o=test,c=de"); $conf->set_Suffix('user', "ou=test,o=test,c=de");
$conf->set_Suffix('group', "ou=testgrp,o=test,c=de"); $conf->set_Suffix('group', "ou=testgrp,o=test,c=de");
$conf->set_Suffix('host', "ou=testhst,o=test,c=de"); $conf->set_Suffix('host', "ou=testhst,o=test,c=de");
$conf->set_Suffix('domain', "ou=testdom,o=test,c=de"); $conf->set_Suffix('smbDomain', "ou=testdom,o=test,c=de");
$conf->set_listAttributes("#uid;#cn", 'user'); $conf->set_listAttributes("#uid;#cn", 'user');
$conf->set_listAttributes("#gidNumber;#cn;#memberUID", 'group'); $conf->set_listAttributes("#gidNumber;#cn;#memberUID", 'group');
$conf->set_listAttributes("#cn;#uid;#description", 'host'); $conf->set_listAttributes("#cn;#uid;#description", 'host');
@ -86,7 +84,7 @@ if ($conf2->get_Adminstring() != "uid=test,o=test,dc=org;uid=root,o=test2,c=de")
if ($conf2->get_Suffix('user') != "ou=test,o=test,c=de") echo ("<br><font color=\"#FF0000\">Saving user suffix failed!</font><br>"); if ($conf2->get_Suffix('user') != "ou=test,o=test,c=de") echo ("<br><font color=\"#FF0000\">Saving user suffix failed!</font><br>");
if ($conf2->get_Suffix('group') != "ou=testgrp,o=test,c=de") echo ("<br><font color=\"#FF0000\">Saving group suffix failed!</font><br>"); if ($conf2->get_Suffix('group') != "ou=testgrp,o=test,c=de") echo ("<br><font color=\"#FF0000\">Saving group suffix failed!</font><br>");
if ($conf2->get_Suffix('host') != "ou=testhst,o=test,c=de") echo ("<br><font color=\"#FF0000\">Saving host suffix failed!</font><br>"); if ($conf2->get_Suffix('host') != "ou=testhst,o=test,c=de") echo ("<br><font color=\"#FF0000\">Saving host suffix failed!</font><br>");
if ($conf2->get_Suffix('domain') != "ou=testdom,o=test,c=de") echo ("<br><font color=\"#FF0000\">Saving domain suffix failed!</font><br>"); if ($conf2->get_Suffix('smbDomain') != "ou=testdom,o=test,c=de") echo ("<br><font color=\"#FF0000\">Saving domain suffix failed!</font><br>");
if ($conf2->get_listAttributes('user') != "#uid;#cn") echo ("<br><font color=\"#FF0000\">Saving userlistAttributes failed!</font><br>"); if ($conf2->get_listAttributes('user') != "#uid;#cn") echo ("<br><font color=\"#FF0000\">Saving userlistAttributes failed!</font><br>");
if ($conf2->get_listAttributes('group') != "#gidNumber;#cn;#memberUID") echo ("<br><font color=\"#FF0000\">Saving grouplistAttributes failed!</font><br>"); if ($conf2->get_listAttributes('group') != "#gidNumber;#cn;#memberUID") echo ("<br><font color=\"#FF0000\">Saving grouplistAttributes failed!</font><br>");
if ($conf2->get_listAttributes('host') != "#cn;#uid;#description") echo ("<br><font color=\"#FF0000\">Saving hostlistAttributes failed!</font><br>"); if ($conf2->get_listAttributes('host') != "#cn;#uid;#description") echo ("<br><font color=\"#FF0000\">Saving hostlistAttributes failed!</font><br>");
@ -106,7 +104,7 @@ $conf2->set_Adminstring($Adminstring);
$conf2->set_Suffix('user', $Suff_users); $conf2->set_Suffix('user', $Suff_users);
$conf2->set_Suffix('group', $Suff_groups); $conf2->set_Suffix('group', $Suff_groups);
$conf2->set_Suffix('host', $Suff_hosts); $conf2->set_Suffix('host', $Suff_hosts);
$conf2->set_Suffix('domain', $Suff_domains); $conf2->set_Suffix('smbDomain', $Suff_domains);
$conf2->set_listAttributes($userlistAttributes, 'user'); $conf2->set_listAttributes($userlistAttributes, 'user');
$conf2->set_listAttributes($grouplistAttributes, 'group'); $conf2->set_listAttributes($grouplistAttributes, 'group');
$conf2->set_listAttributes($hostlistAttributes, 'host'); $conf2->set_listAttributes($hostlistAttributes, 'host');
@ -119,7 +117,5 @@ $conf2->save();
echo ("done<br>"); echo ("done<br>");
// finished // finished
echo ("<br><b><font color=\"#00C000\">Test is complete.</font></b>"); echo ("<br><b><font color=\"#00C000\">Test is complete.</font></b>");
echo ("<br><br><b> Current Config</b><br><br>");
$conf2->printconf();
?> ?>