1 <?php
2 /*
3 This code is part of GOsa (https://gosa.gonicus.de)
4 Copyright (C) 2003 Cajus Pollmeier
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
21 function dump_ldap ($mode= 0)
22 {
23 global $config;
24 $ldap= $config->get_ldap_link();
26 $display = "";
28 if($mode == 2){ // Single Entry Export !
29 $dn = base64_decode($_GET['dn']);
30 $display = $ldap->gen_one_entry($dn);
31 echo $display;
32 }
33 elseif($mode == 3){ // Full LDIF Export !
34 $dn = base64_decode($_GET['dn']);
35 $display = $ldap->gen_ldif($dn);
36 echo $display;
37 }
38 elseif($mode == 4){ // IVBB LDIF Export
39 $dn = base64_decode($_GET['dn']);
40 $display= $ldap->gen_ldif($dn,"(objectClass=ivbbentry)",array(
41 "GouvernmentOrganizationalUnit","houseIdentifier","vocation",
42 "ivbbLastDeliveryCollective","gouvernmentOrganizationalPersonLocality",
43 "gouvernmentOrganizationalUnitDescription","gouvernmentOrganizationalUnitSubjectArea",
44 "functionalTitle","role","certificateSerialNumber","userCertificate","publicVisible",
45 "telephoneNumber","seeAlso","description","title","x121Address","registeredAddress",
46 "destinationIndicator","preferredDeliveryMethod","telexNumber","teletexTerminalIdentifier",
47 "telephoneNumber","internationaliSDNNumber","facsimileTelephoneNumber","street",
48 "postOfficeBox","postalCode","postalAddress","physicalDeliveryOfficeName","ou",
49 "st","l","audio","businessCategory","carLicense","departmentNumber","displayName",
50 "employeeNumber","employeeType","givenName","homePhone","homePostalAddress",
51 "initials","jpegPhoto","labeledURI","mail","manager","mobile","o","pager","photo",
52 "roomNumber","secretary","userCertificate","x500uniqueIdentifier","preferredLanguage",
53 "userSMIMECertificate","userPKCS12"));
55 echo $display;
56 }
57 }
60 /* Basic setup, remove eventually registered sessions */
61 @require_once ("../include/php_setup.inc");
62 @require_once ("functions.inc");
63 error_reporting (E_ALL | E_STRICT);
64 session::start();
65 session::set('errorsAlreadyPosted',array());
67 /* Logged in? Simple security check */
68 if (!session::is_set('ui')){
69 new log("security","all/all","",array(),"Error: getldif.php called without session") ;
70 header ("Location: index.php");
71 exit;
72 }
73 $ui= session::get("ui");
74 $config= session::get('config');
76 /* Check ACL's */
77 $dn = base64_decode($_GET['dn']);
78 $acl = $ui->get_permissions($dn,"ldapmanager/ldifexport");
79 if(!preg_match("/r/",$acl)){
80 msg_dialog::display(_("Permission denied!"),_("You are not allowed to create ldap dumps."),FATAL_ERROR_DIALOG);
81 exit();
82 }
85 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
86 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
87 header("Cache-Control: no-cache");
88 header("Pragma: no-cache");
89 header("Cache-Control: post-check=0, pre-check=0");
91 header("Content-type: text/plain");
94 switch ($_GET['ivbb']){
95 case 2: dump_ldap (2);
96 break;
98 case 3: dump_ldap (3);
99 break;
101 case 4: dump_ldap (4);
102 break;
104 default:
105 echo _("Error in ivbb parameter!");
106 }
107 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
108 ?>