RELEASE 0.9.0
This commit is contained in:
commit
763843c16a
40
INSTALL
Normal file
40
INSTALL
Normal file
@ -0,0 +1,40 @@
|
||||
These instructions assume that you have a working install of:
|
||||
a. A web server (Apache, IIS, etc).
|
||||
b. PHP (with LDAP support)
|
||||
|
||||
Installing phpLDAPAdmin in 4 easy steps:
|
||||
|
||||
1. Untar the archive (if you're reading this, you've already done that).
|
||||
2. Put the resulting phpldapadmin directory somewhere in your webroot.
|
||||
3. Copy 'config.php.example' to 'config.php' and edit to taste.
|
||||
4. Then, point your browser to the phpldapadmin directory.
|
||||
|
||||
Browsers
|
||||
|
||||
phpLDAPAdmin was developed on Mozilla, and will most likely run best thereon.
|
||||
However, testing has been done on Internet Explorer, and it should work
|
||||
well also. No testing has been done on either Konqueror (or any khtml-based
|
||||
browser like Safari) or Opera. If you find a browser incompatibility,
|
||||
please report it.
|
||||
|
||||
Contributors (thank you!)
|
||||
|
||||
Patch writers:
|
||||
|
||||
- Mario Valdez jpegPhoto support, localization (not yet in 0.8.x), html fixes
|
||||
- Bayu Irawan userPassword encryption support, html fixes, ldap_modify fixes
|
||||
- Uwe Ebel short_open_tags fix-it script
|
||||
- Philippe Broussard form auth_type bug report
|
||||
- Andrew Tipton SUP support in schema-fetching
|
||||
- Eigil Bjørgum UTF-8 support
|
||||
- Brandon Lederer DNS entry template
|
||||
Nathan Rotschafer
|
||||
- Steve Rigler Password hash patch
|
||||
- Chric Jackson Blowfish and md5crypt passwords
|
||||
|
||||
Bug reporters:
|
||||
|
||||
- Colin Tinker (short_open_tags bug report)
|
||||
- Greg Felix (multi-value update bug report)
|
||||
- Moritz Mertinkat (creation bug report)
|
||||
|
341
LICENSE
Normal file
341
LICENSE
Normal file
@ -0,0 +1,341 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
|
55
add_oclass.php
Normal file
55
add_oclass.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/*
|
||||
* add_oclass.php
|
||||
* Adds an objectClass to the specified dn.
|
||||
* Variables that come in as POST vars:
|
||||
*
|
||||
* Note, this does not do any schema violation checking. That is
|
||||
* performed in add_oclass_form.php.
|
||||
*
|
||||
* Vars that come in as POST:
|
||||
* - dn (rawurlencoded)
|
||||
* - server_id
|
||||
* - new_oclass
|
||||
* - new_attrs (array, if any)
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require 'functions.php';
|
||||
|
||||
$dn = stripslashes( rawurldecode( $_POST['dn'] ) );
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$new_oclass = stripslashes( $_POST['new_oclass'] );
|
||||
$server_id = $_POST['server_id'];
|
||||
$new_attrs = $_POST['new_attrs'];
|
||||
|
||||
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
|
||||
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
|
||||
|
||||
$new_entry = array();
|
||||
$new_entry['objectClass'] = $new_oclass;
|
||||
|
||||
$new_attrs_entry = array();
|
||||
$new_oclass_entry = array( 'objectClass' => $new_oclass );
|
||||
|
||||
if( is_array( $new_attrs ) && count( $new_attrs ) > 0 )
|
||||
foreach( $new_attrs as $attr => $val )
|
||||
$new_entry[ $attr ] = $val;
|
||||
|
||||
//echo "<pre>";
|
||||
//print_r( $new_entry );
|
||||
//exit;
|
||||
|
||||
$ds = pla_ldap_connect( $server_id ) or pla_error( "Could not connect to LDAP server." );
|
||||
$add_res = @ldap_mod_add( $ds, $dn, $new_entry );
|
||||
|
||||
if( ! $add_res )
|
||||
{
|
||||
pla_error( "Could not perform ldap_mod_add operation", ldap_error( $ds ), ldap_errno( $ds ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
header( "Location: edit.php?server_id=$server_id&dn=$encoded_dn" );
|
||||
}
|
||||
|
||||
?>
|
108
add_oclass_form.php
Normal file
108
add_oclass_form.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* add_oclass_form.php
|
||||
* This page may simply add the objectClass and take you back to the edit page,
|
||||
* but, in one condition it may prompt the user for input. That condition is this:
|
||||
*
|
||||
* If the user has requested to add an objectClass that requires a set of
|
||||
* attributes with 1 or more not defined by the object. In that case, we will
|
||||
* present a form for the user to add those attributes to the object.
|
||||
*
|
||||
* Variables that come in as POST vars:
|
||||
* - dn (rawurlencoded)
|
||||
* - server_id
|
||||
* - new_oclass
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
|
||||
$dn = stripslashes( rawurldecode( $_POST['dn'] ) );
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$new_oclass = stripslashes( $_POST['new_oclass'] );
|
||||
$server_id = $_POST['server_id'];
|
||||
|
||||
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
|
||||
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
|
||||
|
||||
/* Ensure that the object has defined all MUST attrs for this objectClass.
|
||||
* If it hasn't, present a form to have the user enter values for all the
|
||||
* newly required attrs. */
|
||||
|
||||
$entry = get_object_attrs( $server_id, $dn, true );
|
||||
$current_attrs = array();
|
||||
foreach( $entry as $attr => $junk )
|
||||
$current_attrs[] = strtolower($attr);
|
||||
// grab the required attributes for the new objectClass
|
||||
$must_attrs = get_schema_objectclasses( $server_id );
|
||||
$must_attrs = $must_attrs[ strtolower($new_oclass) ]['must_attrs'];
|
||||
sort( $must_attrs );
|
||||
// build a list of the attributes that this new objectClass requires,
|
||||
// but that the object does not currently contain
|
||||
$needed_attrs = array();
|
||||
foreach( $must_attrs as $attr )
|
||||
if( ! in_array( strtolower($attr), $current_attrs ) )
|
||||
$needed_attrs[] = $attr;
|
||||
|
||||
if( count( $needed_attrs ) > 0 )
|
||||
{
|
||||
?>
|
||||
|
||||
|
||||
<?php include 'header.php'; ?>
|
||||
<body>
|
||||
|
||||
<h3 class="title">New Required Attributes</h3>
|
||||
<h3 class="subtitle">This action requires you to add <?php echo count($needed_attrs); ?> new attribute<?php echo (count($needed_attrs)>1?'s':''); ?></h3>
|
||||
|
||||
<small>
|
||||
Instrucitons: In order to add the objectClass <b><?php echo $new_oclass; ?></b> to the object <b><?php echo htmlspecialchars($dn); ?></b>,
|
||||
you must specify <?php echo count( $needed_attrs ); ?> new attribute<?php echo (count($needed_atts)>1?'s':''); ?> that this
|
||||
objectClass requires. You can do so in this form.</small>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<form action="add_oclass.php" method="post">
|
||||
<input type="hidden" name="new_oclass" value="<?php echo htmlspecialchars( $new_oclass ); ?>" />
|
||||
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
|
||||
<table class="edit_dn" cellspacing="0">
|
||||
<tr><th colspan="2">New Required Attributes</th></tr>
|
||||
|
||||
<?php foreach( $needed_attrs as $count => $attr ) { ?>
|
||||
<?php if( $count % 2 == 0 ) { ?>
|
||||
<tr class="row1">
|
||||
<?php } else { ?>
|
||||
<tr class="row2">
|
||||
<?php } ?>
|
||||
<td class="attr"><b><?php echo htmlspecialchars($attr); ?></b></td>
|
||||
<td class="val"><input type="text" name="new_attrs[<?php echo htmlspecialchars($attr); ?>]" value="" size="40" />
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
</table>
|
||||
<br />
|
||||
<br />
|
||||
<center><input type="submit" value="Add ObjectClass and Attributes" /></center>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
$ds = pla_ldap_connect( $server_id ) or pla_error( "Could not connect to LDAP server." );
|
||||
$add_res = @ldap_mod_add( $ds, $dn, array( 'objectClass' => $new_oclass ) );
|
||||
if( ! $add_res )
|
||||
pla_error( "Could not perform ldap_mod_add operation.", ldap_error( $ds ), ldap_errno( $ds ) );
|
||||
else
|
||||
header( "Location: edit.php?server_id=$server_id&dn=$encoded_dn" );
|
||||
|
||||
}
|
||||
|
||||
?>
|
52
add_value.php
Normal file
52
add_value.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* add_value.php
|
||||
* Adds a value to an attribute for a given dn.
|
||||
* Variables that come in as POST vars:
|
||||
* - dn (rawurlencoded)
|
||||
* - attr (rawurlencoded) the attribute to which we are adding a value
|
||||
* - server_id
|
||||
* - new_value (form element)
|
||||
*
|
||||
* On success, redirect to the edit_dn page.
|
||||
* On failure, echo an error.
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
|
||||
$dn = stripslashes( rawurldecode( $_POST['dn'] ) );
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$attr = stripslashes( $_POST['attr'] );
|
||||
$encoded_attr = rawurlencode( $attr );
|
||||
$server_id = $_POST['server_id'];
|
||||
$new_value = stripslashes( $_POST['new_value'] );
|
||||
$new_value = utf8_encode($new_value);
|
||||
|
||||
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
|
||||
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
|
||||
|
||||
$ds = pla_ldap_connect( $server_id ) or pla_error( "Could not connect to LDAP server" );
|
||||
|
||||
// special case for jpegPhoto attributes:
|
||||
// we must go read the data from the file.
|
||||
if( 0 == strcasecmp( $attr, 'jpegPhoto' ) )
|
||||
{
|
||||
$file = $_FILES['jpeg_photo_file']['tmp_name'];
|
||||
$f = fopen( $file, 'r' );
|
||||
$jpeg_data = fread( $f, filesize( $file ) );
|
||||
fclose( $f );
|
||||
$new_value = $jpeg_data;
|
||||
}
|
||||
|
||||
$new_entry = array( $attr => $new_value );
|
||||
|
||||
$add_result = @ldap_mod_add( $ds, $dn, $new_entry );
|
||||
|
||||
if( ! $add_result )
|
||||
pla_error( "Could not perform ldap_mod_add operation.", ldap_error( $ds ), ldap_errno( $ds ) );
|
||||
|
||||
header( "Location: edit.php?server_id=$server_id&dn=$encoded_dn&updated_attr=$encoded_attr" );
|
||||
|
||||
?>
|
133
add_value_form.php
Normal file
133
add_value_form.php
Normal file
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* add_value_form.php
|
||||
* Displays a form to allow the user to enter a new value to add
|
||||
* to the existing list of values for a multi-valued attribute.
|
||||
* Variables that come in as GET vars:
|
||||
* - dn (rawurlencoded)
|
||||
* - attr (rawurlencoded) the attribute to which we are adding a value
|
||||
* - server_id
|
||||
*
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
|
||||
$dn = stripslashes( $_GET['dn'] );
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$server_id = $_GET['server_id'];
|
||||
$rdn = ldap_explode_dn( $dn, 0 );
|
||||
$rdn = $rdn[0];
|
||||
$server_name = $servers[$server_id]['name'];
|
||||
$attr = stripslashes( $_GET['attr'] );
|
||||
$encoded_attr = rawurlencode( $attr );
|
||||
$current_values = get_object_attr( $server_id, $dn, $attr );
|
||||
$num_current_values = ( is_array($current_values) ? count($current_values) : 1 );
|
||||
$is_object_class = ( 0 == strcasecmp( $attr, 'objectClass' ) ) ? true : false;
|
||||
$is_jpeg_photo = ( 0 == strcasecmp( $attr, 'jpegPhoto' ) ) ? true : false;
|
||||
|
||||
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
|
||||
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
|
||||
|
||||
if( $is_object_class ) {
|
||||
// fetch all available objectClasses and remove those from the list that are already defined in the entry
|
||||
$schema_oclasses = get_schema_objectclasses( $server_id );
|
||||
if( ! is_array( $current_values ) )
|
||||
$current_values = array( $current_values );
|
||||
foreach( $current_values as $oclass )
|
||||
unset( $schema_oclasses[ strtolower( $oclass ) ] );
|
||||
} else {
|
||||
$schema_attrs = get_schema_attributes( $server_id );
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php include 'header.php'; ?>
|
||||
|
||||
<body>
|
||||
|
||||
<h3 class="title">New <b><?php echo htmlspecialchars($attr); ?></b> value for <b><?php echo htmlentities($rdn); ?></b></h3>
|
||||
<h3 class="subtitle">Server: <b><?php echo $server_name; ?></b> Distinguished Name: <b><?php echo $dn; ?></b></h3>
|
||||
|
||||
Current list of <b><?php echo $num_current_values; ?></b> value<?php echo $num_current_values>1?'s':''; ?>
|
||||
for attribute <b><?php echo htmlspecialchars($attr); ?></b>:
|
||||
|
||||
<?php if( $is_jpeg_photo ) { ?>
|
||||
|
||||
<table><td>
|
||||
<?php draw_jpeg_photos( $server_id, $dn ); ?>
|
||||
</td></table>
|
||||
|
||||
<!-- Temporary warning until we find a way to add jpegPhoto values without an INAPROPRIATE_MATCHING error -->
|
||||
<p><small>
|
||||
Note: You will get an "inappropriate matching" error if you have not<br />
|
||||
setup an <tt>EQUALITY</tt> rule on your LDAP server for <tt>jpegPhoto</tt> attributes.
|
||||
</small></p>
|
||||
<!-- End of temporary warning -->
|
||||
|
||||
<?php } else { ?>
|
||||
|
||||
<ul class="current_values">
|
||||
<?php if( is_array( $current_values ) ) /*$num_current_values > 1 )*/ {
|
||||
foreach( $current_values as $val ) { ?>
|
||||
|
||||
<li><nobr><?php echo htmlspecialchars(utf8_decode($val)); ?></nobr></li>
|
||||
|
||||
<?php } ?>
|
||||
<?php } else { ?>
|
||||
|
||||
<li><nobr><?php echo htmlspecialchars(utf8_decode($current_values)); ?></nobr></li>
|
||||
|
||||
<?php } ?>
|
||||
</ul>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
Enter the value you would like to add:<br />
|
||||
<br />
|
||||
|
||||
<?php if( $is_object_class ) { ?>
|
||||
|
||||
<form action="add_oclass_form.php" method="post" class="new_value">
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
|
||||
<select name="new_oclass">
|
||||
|
||||
<?php foreach( $schema_oclasses as $oclass => $desc ) { ?>
|
||||
|
||||
<option value="<?php echo $desc['name']; ?>"><?php echo $desc['name']; ?></option>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</select> <input type="submit" value="Add new objectClass" />
|
||||
|
||||
<br /><small>Note: you may be required to enter new attributes<br />
|
||||
that this objectClass requires (MUST attrs)</small>
|
||||
|
||||
<?php } elseif( $is_jpeg_photo ) { ?>
|
||||
|
||||
<form action="add_value.php" method="post" class="new_value" enctype="multipart/form-data">
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
|
||||
<input type="hidden" name="attr" value="<?php echo $encoded_attr; ?>" />
|
||||
<input type="file" name="jpeg_photo_file" value="" /><br />
|
||||
<br />
|
||||
<input type="submit" name="submit" value="Add new jpeg >>" />
|
||||
|
||||
<?php } else { ?>
|
||||
|
||||
<form action="add_value.php" method="post" class="new_value">
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
<input type="hidden" name="dn" value="<?php echo $encoded_dn; ?>" />
|
||||
<input type="hidden" name="attr" value="<?php echo $encoded_attr; ?>" />
|
||||
<input type="text" name="new_value" size="40" value="" />
|
||||
<input type="submit" name="submit" value="Add New Value" />
|
||||
<br />
|
||||
<small>Syntax: <?php echo $schema_attrs[ strtolower($attr) ]['type']; ?></small>
|
||||
</form>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</body>
|
||||
</html>
|
43
collapse.php
Normal file
43
collapse.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* collapse.php
|
||||
* This script alters the session variable 'tree', collapsing it
|
||||
* at the dn specified in the query string.
|
||||
*
|
||||
* Variables that come in as GET vars:
|
||||
* - dn (rawurlencoded)
|
||||
* - server_id
|
||||
*
|
||||
* Note: this script is equal and opposite to expand.php
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
|
||||
$dn = stripslashes( $_GET['dn'] );
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$server_id = $_GET['server_id'];
|
||||
|
||||
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
|
||||
|
||||
session_start();
|
||||
session_is_registered( 'tree' ) or pla_error( "Your session tree is not registered. That's weird. Shouldn't ever happen".
|
||||
". Just go back and it should be fixed automagically." );
|
||||
$tree = $_SESSION['tree'];
|
||||
|
||||
// and remove this instance of the dn as well
|
||||
unset( $tree[$server_id][$dn] );
|
||||
|
||||
$_SESSION['tree'] = $tree;
|
||||
session_write_close();
|
||||
|
||||
// This is for Opera. By putting "random junk" in the query string, it thinks
|
||||
// that it does not have a cached version of the page, and will thus
|
||||
// fetch the page rather than display the cached version
|
||||
$time = gettimeofday();
|
||||
$random_junk = md5( strtotime( 'now' ) . $time['usec'] );
|
||||
|
||||
header( "Location: tree.php?foo=$random_junk#{$server_id}_{$encoded_dn}" );
|
||||
|
||||
; ?>
|
163
config.php.example
Normal file
163
config.php.example
Normal file
@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The phpLDAPAdmin config file
|
||||
* This is where you customize phpLDAPAdmin. The most important
|
||||
* part is immediately below: The "LDAP Servers" section.
|
||||
* You must specify at least one LDAP server there.
|
||||
*/
|
||||
|
||||
// Required Configuration
|
||||
|
||||
// Your LDAP servers
|
||||
$i=0;
|
||||
$servers = array();
|
||||
$servers[$i]['name'] = 'My LDAP Server'; /* A convenient name that will appear in the tree viewer */
|
||||
$servers[$i]['host'] = 'ldap.example.com'; /* Examples: 'ldap.example.com', 'ldaps://ldap.example.com/'
|
||||
Note: Leave blank to remove it from the list of servers in the
|
||||
tree viewer*/
|
||||
$servers[$i]['base'] = 'dc=example,dc=com';/* The base DN of your LDAP server. Leave this blank to have phpLDAPAdmin
|
||||
auto-detect it for you. */
|
||||
$servers[$i]['port'] = 389; /* The port your LDAP server listens on (no quotes) */
|
||||
$servers[$i]['auth_type'] = 'config'; /* 2 options: 'form': you will be prompted, and a cookie stored
|
||||
with your login dn and password. 'config': specify your login dn
|
||||
and password here. In both cases, use caution! */
|
||||
$servers[$i]['login_dn'] = 'cn=Manager,dc=example,dc=com'; /* For anonymous binds, leave the login_dn and
|
||||
login_pass blank */
|
||||
$servers[$i]['login_pass'] = 'secret'; /* Your password (only if you specified 'config' for 'auth_type' */
|
||||
$servers[$i]['tls'] = false; /* Use TLS to connect. Requires PHP 4.2 or greater */
|
||||
|
||||
/* If you want to configure an additional LDAP server, do so below. */
|
||||
$i++;
|
||||
$servers[$i]['name'] = 'Another server';
|
||||
$servers[$i]['host'] = '';
|
||||
$servers[$i]['base'] = 'dc=example,dc=com';
|
||||
$servers[$i]['port'] = 389;
|
||||
$servers[$i]['auth_type'] = 'config';
|
||||
$servers[$i]['login_dn'] = '';
|
||||
$servers[$i]['login_pass'] = '';
|
||||
$servers[$i]['tls'] = false;
|
||||
|
||||
$i++;
|
||||
$servers[$i]['name'] = 'Another server';
|
||||
$servers[$i]['host'] = '';
|
||||
$servers[$i]['base'] = 'dc=example,dc=com';
|
||||
$servers[$i]['port'] = 389;
|
||||
$servers[$i]['auth_type'] = 'config';
|
||||
$servers[$i]['login_dn'] = '';
|
||||
$servers[$i]['login_pass'] = '';
|
||||
$servers[$i]['tls'] = false;
|
||||
|
||||
/* If you want to configure more LDAP servers, copy and paste the sections above (including the "$i++;") */
|
||||
|
||||
|
||||
// The temporary storage directory where we will put jpegPhoto data
|
||||
// This directory must be readable and writable by your web server
|
||||
$jpeg_temp_dir = "/tmp"; // for Unix systems
|
||||
//$jpeg_temp_dir = "c:\\temp"; // for Windows systems
|
||||
|
||||
|
||||
// Optional Configuration Below
|
||||
|
||||
/** **/
|
||||
/** Appearance and Behavior **/
|
||||
/** **/
|
||||
|
||||
// If you used auth_type 'form' in the servers list, you can adjust how long the cookie will last
|
||||
// (default is 0 seconds, which expires when you close the browser)
|
||||
$cookie_time = 0;
|
||||
|
||||
// How many pixels wide do you want your left frame view (for the tree browser)
|
||||
$tree_width = 300;
|
||||
|
||||
// Do you want phpLDAPAdmin to check the schema of the server when you edit a DN and draw
|
||||
// specialized for elements based on that schema (ie, for booleans, draw a true/false
|
||||
// drop-down instead of a text box). This may cause a performance slow-down.
|
||||
// Note:
|
||||
// This will have problems with non-LDAP compliant servers that do not properly represent
|
||||
// their schema.
|
||||
$edit_dn_schema_lookup = true;
|
||||
|
||||
// How long to keep jpegPhoto temporary files around (in seconds)
|
||||
$jpeg_tmp_keep_time = 120;
|
||||
|
||||
/** **/
|
||||
/** Simple Search Form Config **/
|
||||
/** **/
|
||||
|
||||
// Which attributes to include in the drop-down menu of the simple search form (comma-separated)
|
||||
$search_attributes = "uid, cn, gidNumber";
|
||||
|
||||
// This list correlates to the list directly above. If you want to present more readable names
|
||||
// for your search attributes, do so here. Both lists must have the same number of entries.
|
||||
$search_attributes_display = "User Name, Full Name, Group ID";
|
||||
|
||||
// The list of attributes to display in each search result entry summary
|
||||
$search_result_attributes = "dn, cn";
|
||||
|
||||
// Search methods in the drop down box for the simple search form
|
||||
// (if you change this, you will also have to edit search.php to properly handle the new option)
|
||||
$search_criteria_options = "equals, starts with, contains, ends with, sounds like";
|
||||
|
||||
/** **/
|
||||
/** Templates for entry creation **/
|
||||
/** **/
|
||||
|
||||
$templates = array();
|
||||
|
||||
// Fill in this array with templates that you can create to suit your needs.
|
||||
// Each entry defines a description (for display in the template list) and
|
||||
// a handler, which is a file that will be executed with certain POST vars set.
|
||||
// See the templates provided here for an example of how to make your own template.
|
||||
|
||||
$templates[] =
|
||||
array( 'desc' => 'User',
|
||||
'icon' => 'images/user.png',
|
||||
'handler' => 'new_user_template.php' );
|
||||
|
||||
$templates[] =
|
||||
array( 'desc' => 'inetOrgPerson',
|
||||
'icon' => 'images/user.png',
|
||||
'handler' => 'new_address_template.php' );
|
||||
|
||||
$templates[] =
|
||||
array( 'desc' => 'Organizational Unit',
|
||||
'icon' => 'images/ou.png',
|
||||
'handler' => 'new_ou_template.php' );
|
||||
|
||||
$templates[] =
|
||||
array( 'desc' => 'Samba NT Machine',
|
||||
'icon' => 'images/terminal.png',
|
||||
'handler' => 'new_nt_machine.php' );
|
||||
|
||||
$templates[] =
|
||||
array( 'desc' => 'DNS Entry',
|
||||
'icon' => 'images/dc.png',
|
||||
'handler' => 'new_dns_entry.php' );
|
||||
|
||||
/** **/
|
||||
/** User-friendly attribute translation **/
|
||||
/** **/
|
||||
|
||||
$friendly_attrs = array();
|
||||
|
||||
// Use this array to map attribute names to user friendly names. For example, if you
|
||||
// don't want to see "facsimileTelephoneNumber" but rather "Fax".
|
||||
|
||||
$friendly_attrs[ 'facsimileTelephoneNumber' ] = 'Fax';
|
||||
$friendly_attrs[ 'telephoneNumber' ] = 'Phone';
|
||||
|
||||
/** **/
|
||||
/** Some phpLDAPAdmin code to be executed. No touchy. **/
|
||||
/** **/
|
||||
|
||||
// Turn off notices about referencing arrays and such, but leave everything else on.
|
||||
error_reporting( E_ALL ^ E_NOTICE );
|
||||
|
||||
// Always including the 'custom' template (the most generic and flexible)
|
||||
$templates['custom'] =
|
||||
array( 'desc' => 'Custom',
|
||||
'icon' => 'images/object.png',
|
||||
'handler' => 'custom.php' );
|
||||
|
||||
?>
|
167
copy.php
Normal file
167
copy.php
Normal file
@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* copy.php
|
||||
* Copies a given object to create a new one.
|
||||
*
|
||||
* Vars that come in as POST vars
|
||||
* - source_dn (rawurlencoded)
|
||||
* - new_dn (form element)
|
||||
* - server_id
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
|
||||
session_start();
|
||||
|
||||
$source_dn = stripslashes( rawurldecode( $_POST['old_dn'] ) );
|
||||
$dest_dn = stripslashes( $_POST['new_dn'] );
|
||||
$encoded_dn = rawurlencode( $old_dn );
|
||||
$source_server_id = $_POST['server_id'];
|
||||
$dest_server_id = $_POST['dest_server_id'];
|
||||
$do_recursive = $_POST['recursive'] == 'on' ? true : false;
|
||||
|
||||
check_server_id( $source_server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $source_server_id ) );
|
||||
have_auth_info( $source_server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
|
||||
check_server_id( $dest_server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $dest_server_id ) );
|
||||
have_auth_info( $dest_server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
|
||||
|
||||
include 'header.php';
|
||||
|
||||
/* Error checking */
|
||||
if( 0 == strlen( trim( $dest_dn ) ) )
|
||||
pla_error( "You left the destination DN blank." );
|
||||
|
||||
if( strcasecmp( $source_dn,$dest_dn ) == 0 && $source_server_id == $dest_server_id )
|
||||
pla_error( "The source and destination DN are the same." );
|
||||
|
||||
if( $do_recursive ) {
|
||||
// build a tree similar to that of the tree browser to give to r_copy_dn
|
||||
$snapshot_tree = array();
|
||||
include 'header.php';
|
||||
echo "<body>\n";
|
||||
echo "<h3 class=\"title\">Copying " . htmlspecialchars( $source_dn ) . "</h3>\n";
|
||||
echo "<h3 class=\"subtitle\">Recursive copy progress</h3>\n";
|
||||
echo "<br /><br />";
|
||||
echo "<small>\n";
|
||||
echo "Building snapshot of tree to copy... ";
|
||||
flush();
|
||||
build_tree( $source_server_id, $source_dn, $snapshot_tree );
|
||||
echo " <span style=\"color:green\">Success</span><br />\n";
|
||||
flush();
|
||||
|
||||
// prevent script from bailing early on a long delete
|
||||
@set_time_limit( 0 );
|
||||
|
||||
$copy_result = r_copy_dn( $source_server_id, $dest_server_id, $snapshot_tree, $source_dn, $dest_dn );
|
||||
echo "</small>\n";
|
||||
} else {
|
||||
$copy_result = copy_dn( $source_server_id, $source_dn, $dest_server_id, $dest_dn );
|
||||
}
|
||||
|
||||
if( $copy_result )
|
||||
{
|
||||
$edit_url="edit.php?server_id=$dest_server_id&dn=" . rawurlencode( $dest_dn );
|
||||
$new_rdn = get_rdn( $dest_dn );
|
||||
$container = get_container( $dest_dn );
|
||||
if( session_is_registered( 'tree' ) )
|
||||
{
|
||||
$tree = $_SESSION['tree'];
|
||||
$tree_icons = $_SESSION['tree_icons'];
|
||||
if( isset( $tree[$dest_server_id][$container] ) )
|
||||
{
|
||||
$tree[$dest_server_id][$container][] = $dest_dn;
|
||||
$tree_icons[$dest_server_id][$dest_dn] = get_icon( $dest_server_id, $dest_dn );
|
||||
$_SESSION['tree'] = $tree;
|
||||
$_SESSION['tree_icons'] = $tree_icons;
|
||||
session_write_close();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!-- refresh the tree view (with the new DN renamed)
|
||||
and redirect to the edit_dn page -->
|
||||
<script language="javascript">
|
||||
parent.left_frame.location.reload();
|
||||
</script>
|
||||
<br />
|
||||
Copy successful! Would you like to <a href="<?php echo $edit_url; ?>">view the new entry</a>?
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
function r_copy_dn( $source_server_id, $dest_server_id, &$tree, $root_dn, $dest_dn )
|
||||
{
|
||||
echo "<nobr>Copying " . htmlspecialchars( utf8_decode( $root_dn ) ) . "...";
|
||||
flush();
|
||||
$copy_result = copy_dn( $source_server_id, $root_dn, $dest_server_id, $dest_dn );
|
||||
|
||||
if( ! $copy_result ) {
|
||||
global $R_COPY_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
echo "<span style=\"color:green\">Success</span></nobr><br />\n";
|
||||
flush();
|
||||
|
||||
$children = $tree[ $root_dn ];
|
||||
if( is_array( $children ) && count( $children ) > 0 )
|
||||
{
|
||||
foreach( $children as $child_dn ) {
|
||||
$child_rdn = get_rdn( $child_dn );
|
||||
$new_dest_dn = $child_rdn . ',' . $dest_dn;
|
||||
r_copy_dn( $source_server_id, $dest_server_id, $tree, $child_dn, $new_dest_dn );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function copy_dn( $source_server_id, $source_dn, $dest_server_id, $dest_dn )
|
||||
{
|
||||
global $ds;
|
||||
$ds = pla_ldap_connect( $dest_server_id ) or pla_error( "Could not connect to LDAP server" );
|
||||
$attrs = get_object_attrs( $source_server_id, $source_dn );
|
||||
$new_entry = $attrs;
|
||||
// modify the prefix-value (ie "bob" in cn=bob) to match the destination DN's value.
|
||||
$rdn_attr = substr( $dest_dn, 0, strpos( $dest_dn, '=' ) );
|
||||
$rdn_value = get_rdn( $dest_dn );
|
||||
$rdn_value = substr( $rdn_value, strpos( $rdn_value, '=' ) + 1 );
|
||||
$new_entry[ $rdn_attr ] = $rdn_value;
|
||||
// don't need a dn attribute in the new entry
|
||||
unset( $new_entry['dn'] );
|
||||
$add_result = @ldap_add( $ds, $dest_dn, $new_entry );
|
||||
if( ! $add_result ) {
|
||||
echo "</small><br /><br />";
|
||||
pla_error( "Failed to copy $source_dn (server: $source_server_id) to " .
|
||||
"$dest_dn (server: $dest_server_id)", ldap_error( $ds ), ldap_errno( $ds ) );
|
||||
}
|
||||
|
||||
return $add_result;
|
||||
}
|
||||
|
||||
function build_tree( $source_server_id, $root_dn, &$tree )
|
||||
{
|
||||
$children = get_container_contents( $source_server_id, $root_dn );
|
||||
if( is_array( $children ) && count( $children ) > 0 )
|
||||
{
|
||||
$tree[ $root_dn ] = $children;
|
||||
foreach( $children as $child_dn )
|
||||
build_tree( $source_server_id, $child_dn, $tree );
|
||||
}
|
||||
|
||||
}
|
86
copy_form.php
Normal file
86
copy_form.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* copy_form.php
|
||||
* Copies a given object to create a new one.
|
||||
*
|
||||
* - dn (rawurlencoded)
|
||||
* - server_id
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
|
||||
$dn = stripslashes( rawurldecode( $_GET['dn'] ) );
|
||||
$encoded_dn = rawurlencode( $dn );
|
||||
$server_id = $_GET['server_id'];
|
||||
$rdn = ldap_explode_dn( $dn, 0 );
|
||||
$container = $rdn[ 1 ];
|
||||
for( $i=2; $i<count($rdn)-1; $i++ )
|
||||
$container .= ',' . $rdn[$i];
|
||||
$rdn = $rdn[0];
|
||||
|
||||
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
|
||||
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
|
||||
|
||||
$attrs = get_object_attrs( $server_id, $dn );
|
||||
$server_name = $servers[$server_id]['name'];
|
||||
|
||||
$select_server_html = "";
|
||||
foreach( $servers as $id => $server )
|
||||
{
|
||||
if( $server['host'] )
|
||||
{
|
||||
$select_server_html .= "<option value=\"$id\"". ($id==$server_id?" selected":"") .">" . $server['name'] . "</option>\n";
|
||||
}
|
||||
}
|
||||
|
||||
$children = get_container_contents( $server_id, $dn );
|
||||
|
||||
?>
|
||||
|
||||
<?php include 'header.php'; ?>
|
||||
<body>
|
||||
|
||||
<h3 class="title">Copy <?php echo $rdn; ?></h3>
|
||||
<h3 class="subtitle">Server: <b><?php echo $server_name; ?></b> Distinguished Name: <b><?php echo $dn; ?></b></h3>
|
||||
|
||||
<center>
|
||||
Copy <b><?php echo htmlspecialchars($rdn); ?></b> to a new object:<br />
|
||||
<br />
|
||||
<form action="copy.php" method="post" name="copy_form">
|
||||
<input type="hidden" name="old_dn" value="<?php echo $encoded_dn; ?>" />
|
||||
<input type="hidden" name="server_id" value="<?php echo $server_id; ?>" />
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>Destination DN:</td>
|
||||
<td>
|
||||
<input type="text" name="new_dn" size="45" value="<?php echo htmlspecialchars($dn); ?>" />
|
||||
<?php draw_chooser_link( 'copy_form.new_dn' ); ?></td>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Destination Server:</td>
|
||||
<td><select name="dest_server_id"><?php echo $select_server_html; ?></select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><small>Note: Copying between different servers only works if there are no schema violations</small></td>
|
||||
</tr>
|
||||
<?php if( is_array( $children ) && count( $children ) > 0 ) { ?>
|
||||
<tr>
|
||||
<td colspan="2"><input type="checkbox" name="recursive" />
|
||||
Recursively copy all children of this object as well.</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
<tr>
|
||||
<td colspan="2" align="right"><input type="submit" value="Copy" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
114
create.php
Normal file
114
create.php
Normal file
@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* create.php
|
||||
* Creates a new object.
|
||||
*
|
||||
* Variables that come in as POST vars:
|
||||
* - new_dn
|
||||
* - attrs (an array of attributes)
|
||||
* - vals (an array of values for the above attrs)
|
||||
* - required_attrs (an array with indices being the attributes,
|
||||
* and the values being their respective values)
|
||||
* - object_classes (rawurlencoded, and serialized array of objectClasses)
|
||||
* - server_id
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
|
||||
$new_dn = stripslashes( $_POST['new_dn'] );
|
||||
$new_dn = utf8_encode( $new_dn );
|
||||
$encoded_dn = rawurlencode( $new_dn );
|
||||
$server_id = $_POST['server_id'];
|
||||
$vals = $_POST['vals'];
|
||||
$attrs = $_POST['attrs'];
|
||||
$required_attrs = $_POST['required_attrs'];
|
||||
$object_classes = unserialize( rawurldecode( $_POST['object_classes'] ) );
|
||||
$container = get_container( $new_dn );
|
||||
|
||||
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
|
||||
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
|
||||
|
||||
// build the new entry
|
||||
$new_entry = array();
|
||||
if( isset( $required_attrs ) && is_array( $required_attrs ) )
|
||||
{
|
||||
foreach( $required_attrs as $attr => $val )
|
||||
{
|
||||
if( $val == '' )
|
||||
pla_error( "Error, you left the value for required attribute <b>" .
|
||||
htmlspecialchars( $attr ) . "</b> blank." );
|
||||
|
||||
$attr = stripslashes( $attr );
|
||||
$val = stripslashes( $val );
|
||||
$new_entry[ $attr ][] = utf8_encode( $val );
|
||||
}
|
||||
}
|
||||
|
||||
if( isset( $vals ) && is_array( $vals ) )
|
||||
{
|
||||
foreach( $vals as $i => $val )
|
||||
{
|
||||
$val = stripslashes( $val );
|
||||
$attr = $attrs[$i];
|
||||
$attr = stripslashes( $attr );
|
||||
if( trim($val) )
|
||||
$new_entry[ $attr ][] = utf8_encode( $val );
|
||||
}
|
||||
}
|
||||
|
||||
$new_entry['objectClass'] = $object_classes;
|
||||
if( ! in_array( 'top', $new_entry['objectClass'] ) )
|
||||
$new_entry['objectClass'][] = 'top';
|
||||
|
||||
$ds = pla_ldap_connect( $server_id );
|
||||
$add_result = @ldap_add( $ds, $new_dn, $new_entry );
|
||||
if( $add_result )
|
||||
{
|
||||
$edit_url="edit.php?server_id=$server_id&dn=" . rawurlencode( $new_dn );
|
||||
|
||||
// update the session tree to reflect the change
|
||||
session_start();
|
||||
if( session_is_registered( 'tree' ) )
|
||||
{
|
||||
$tree = $_SESSION['tree'];
|
||||
$tree_icons = $_SESSION['tree_icons'];
|
||||
|
||||
if( isset( $tree[$server_id][$container] ) ) {
|
||||
$tree[$server_id][$container][] = $new_dn;
|
||||
$tree_icons[$server_id][$new_dn] = get_icon( $server_id, $new_dn );
|
||||
}
|
||||
|
||||
$_SESSION['tree'] = $tree;
|
||||
$_SESSION['tree_icons'] = $tree_icons;
|
||||
session_write_close();
|
||||
}
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<?php if( isset( $tree[$server_id][$container] ) ) { ?>
|
||||
|
||||
<!-- refresh the tree view (with the new DN renamed)
|
||||
and redirect to the edit_dn page -->
|
||||
<script language="javascript">
|
||||
parent.left_frame.location.reload();
|
||||
</script>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<meta http-equiv="refresh" content="0; url=<?php echo $edit_url; ?>" />
|
||||
</head>
|
||||
<body>
|
||||
Redirecting... <a href="<?php echo $edit_url; ?>">here</a>.
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
pla_error( "Could not add the object to the LDAP server.", ldap_error( $ds ), ldap_errno( $ds ) );
|
||||
}
|
||||
|
||||
?>
|
81
create_form.php
Normal file
81
create_form.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* create_form.php
|
||||
* The menu where the user chooses an RDN, Container, and Template for creating a new entry.
|
||||
* After submitting this form, the user is taken to their chosen Template handler.
|
||||
*
|
||||
* Variables that come in as GET vars
|
||||
* - server_id (optional)
|
||||
* - container (rawurlencoded) (optional)
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
|
||||
$server_id = $_REQUEST['server_id'];
|
||||
$step = $_REQUEST['step'] ? $_REQUEST['step'] : 1; // defaults to 1
|
||||
$container = stripslashes( $_REQUEST['container'] );
|
||||
|
||||
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
|
||||
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
|
||||
$server_name = $servers[$server_id]['name'];
|
||||
|
||||
// build the server drop-down html
|
||||
$server_menu_html = '<select name="server_id">';
|
||||
$js_dn_list = '';
|
||||
foreach( $servers as $id => $server ) {
|
||||
if( $server['host'] ) {
|
||||
$server_menu_html .= '<option value="'.$id.'"' . ( $id==$server_id? ' selected' : '' ) . '>';
|
||||
$server_menu_html .= $server['name'] . '</option>';
|
||||
}
|
||||
}
|
||||
$server_menu_html .= '</select>';
|
||||
|
||||
?>
|
||||
|
||||
<?php include 'header.php'; ?>
|
||||
|
||||
<body>
|
||||
|
||||
<h3 class="title">Create Object</h3>
|
||||
<h3 class="subtitle">Choose a template</h3>
|
||||
<center><h3>Select a template for the creation process</h3></center>
|
||||
<form action="creation_template.php" method="post">
|
||||
<input type="hidden" name="container" value="<?php echo htmlspecialchars( $container ); ?>" />
|
||||
<table class="create">
|
||||
<tr>
|
||||
<td class="heading">Server:</td>
|
||||
<td><?php echo $server_menu_html; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="heading">Template:</td>
|
||||
<td>
|
||||
<table class="templates">
|
||||
|
||||
<?php foreach( $templates as $name => $template ) { ?>
|
||||
<tr>
|
||||
<td><input type="radio"
|
||||
name="template"
|
||||
value="<?php echo htmlspecialchars($name);?>"
|
||||
id="<?php echo htmlspecialchars($name); ?>" /></td>
|
||||
<td><label for="<?php echo htmlspecialchars($name);?>">
|
||||
<img src="<?php echo $template['icon']; ?>" /></label></td>
|
||||
<td><label for="<?php echo htmlspecialchars($name);?>">
|
||||
<?php echo htmlspecialchars( $template['desc'] ); ?></label></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2"><center><input type="submit" name="submit" value="Proceed >>" /></center></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
45
creation_template.php
Normal file
45
creation_template.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
|
||||
/* file: creation_template.php
|
||||
* This file simply acts as a plugin grabber for the creator templates in
|
||||
* the directory templates/creation/
|
||||
*
|
||||
* Expected POST vars:
|
||||
* server_id
|
||||
* template
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
|
||||
|
||||
$template = stripslashes( $_POST['template'] );
|
||||
$template = $templates[$template];
|
||||
$server_id = $_POST['server_id'];
|
||||
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
|
||||
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
|
||||
$server_name = $servers[ $server_id ][ 'name' ];
|
||||
|
||||
include 'header.php';
|
||||
|
||||
?>
|
||||
|
||||
<body>
|
||||
<h3 class="title">Create Object</h3>
|
||||
<h3 class="subtitle">On server '<?php echo htmlspecialchars( $server_name ); ?>',
|
||||
using template '<?php echo htmlspecialchars( $template['desc'] ); ?>'</h3>
|
||||
|
||||
<?php
|
||||
|
||||
if( ! isset( $_POST['template'] ) )
|
||||
pla_error( "No template specified in POST variables.\n" );
|
||||
|
||||
$handler = 'templates/creation/' . $template['handler'];
|
||||
if( file_exists( $handler ) )
|
||||
include $handler;
|
||||
else
|
||||
pla_error( "Your config specifies a handler of <b>" . htmlspecialchars( $template['handler'] ) .
|
||||
"</b> for this template. But, this handler does not exist in the 'templates/creation' directory." );
|
||||
|
||||
|
65
delete.php
Normal file
65
delete.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* delete.php
|
||||
* Deletes a DN and presents a "job's done" message.
|
||||
*
|
||||
* Variables that come in as POST vars:
|
||||
* - dn (rawurlencoded)
|
||||
* - server_id
|
||||
*/
|
||||
|
||||
require 'config.php';
|
||||
require_once 'functions.php';
|
||||
|
||||
$encoded_dn = $_POST['dn'];
|
||||
$dn = stripslashes( rawurldecode( $encoded_dn ) );
|
||||
$server_id = $_POST['server_id'];
|
||||
|
||||
if( $dn === null )
|
||||
pla_error( "You must specify a DN." );
|
||||
|
||||
check_server_id( $server_id ) or pla_error( "Bad server_id: " . htmlspecialchars( $server_id ) );
|
||||
have_auth_info( $server_id ) or pla_error( "Not enough information to login to server. Please check your configuration." );
|
||||
|
||||
$ds = pla_ldap_connect( $server_id ) or pla_error( "Could not connect to LDAP server" );
|
||||
$del_result = @ldap_delete( $ds, $dn );
|
||||
|
||||
if( $del_result )
|
||||
{
|
||||
// kill the DN from the tree browser session variable and
|
||||
// refresh the tree viewer frame (left_frame)
|
||||
|
||||
session_start();
|
||||
if( session_is_registered( 'tree' ) )
|
||||
{
|
||||
$tree = $_SESSION['tree'];
|
||||
|
||||
// does it have children? (it shouldn't, but hey, you never know)
|
||||
if( isset( $tree[$server_id][$dn] ) )
|
||||
unset( $tree[$server_id][$dn] );
|
||||
|
||||
// search and destroy
|
||||
foreach( $tree[$server_id] as $tree_dn => $subtree )
|
||||
foreach( $subtree as $key => $sub_tree_dn )
|
||||
if( 0 == strcasecmp( $sub_tree_dn, $dn ) )
|
||||
unset( $tree[$server_id][$tree_dn][$key] );
|
||||
}
|
||||
|
||||
$_SESSION['tree'] = $tree;
|
||||
session_write_close();
|
||||
|
||||
?>
|
||||
|
||||
<script language="javascript">
|
||||
parent.left_frame.location.reload();
|
||||
</script>
|
||||
|
||||
Object deleted successfully.
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
} else {
|
||||
pla_error( "Could not delete the object: " . htmlspecialchars( utf8_decode( $dn ) ), ldap_error( $ds ), ldap_errno( $ds ) );
|
||||
}
|