-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdump_object.php
More file actions
126 lines (107 loc) · 4.42 KB
/
dump_object.php
File metadata and controls
126 lines (107 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
// Dump either a specific object or a specific LDAP branch
// $Id: dump_object.php,v 1.8 2007-02-26 10:21:49 turbo Exp $
// {{{ Setup session etc
require("./include/pql_session.inc");
require($_SESSION["path"]."/include/pql_config.inc");
// }}}
if(empty($_REQUEST["submit"])) {
// scope=subtree. Ask for inclusion of operational attributes and if to follow referrals
include($_SESSION["path"]."/header.html");
?>
<form action="<?php echo $_SERVER["PHP_SELF"]?>" method="post">
<input type="hidden" name="scope" value="<?php echo $_REQUEST["scope"]?>">
<input type="hidden" name="dn" value="<?php echo urlencode($_REQUEST["dn"])?>">
<input type="hidden" name="domain" value="<?php echo urlencode($_REQUEST["domain"])?>">
<span class="title3"><?php echo $LANG->_('Search options')?></span><br>
<!-- TODO: The code to follow referrals isn''t implemented in 'include/pql.inc:search()' -->
<!-- <input type="checkbox" name="referrals"> <?php echo $LANG->_('Follow referrals')?><br> -->
<input type="checkbox" name="operationals" CHECKED> <?php echo $LANG->_('Include operational attributes')?><br>
<p>
<span class="title3"><?php echo $LANG->_('Output format/destination')?></span><br>
<input type="radio" name="output" value="browser" CHECKED>Output to browser (in this frame)<br>
<input type="radio" name="output" value="file">Save file locally<br>
<br>
<input type="submit" name="submit" value="<?php echo $LANG->_('Go')?>">
</form>
</body>
</html>
<?php
} else {
if(empty($_REQUEST["referrals"]))
$_REQUEST["referrals"] = 0;
else
$_REQUEST["referrals"] = 1;
if(empty($_REQUEST["operationals"]))
$_REQUEST["operationals"] = 0;
else
$_REQUEST["operationals"] = 1;
if($_REQUEST["scope"] == "sub") {
// scope=subtree. Search and retreive object(s).
// TODO: If 'domain' is empty, try to use the 'dn', but a couple of
// levels up...
$dn = $_REQUEST["domain"];
// Get the non-operational attributes for all objects below DN.
$objects1 = $_pql->search($dn, pql_get_define("PQL_ATTR_OBJECTCLASS").'=*', "SUBTREE", $_REQUEST["referrals"]);
for($i=0; $i < count($objects1); $i++) {
if($_REQUEST["operationals"])
// Get the operational attributes for each object
$objects2 = $_pql->search($objects1[$i]["dn"], pql_get_define("PQL_ATTR_OBJECTCLASS").'=*', "BASE", $_REQUEST["referrals"],
array('structuralObjectClass', 'entryUUID', 'creatorsName', 'createTimestamp', 'OpenLDAPaci', 'entryCSN', 'modifiersName',
'modifyTimestamp', 'subschemaSubentry', 'hasSubordinates', 'aci'));
// URL decode a 'DNS TTL RDN'.
if(preg_match("/^dNSTTL=/i", $objects1[$i]["dn"]))
$objects1[$i]["dn"] = urldecode($objects1[$i]["dn"]);
if($_REQUEST["operationals"])
// Merge the two arrays
$objects = $objects1[$i] + $objects2;
else
$objects = $objects1[$i];
// Create the LDIF section for this object
if(empty($LDIF))
$LDIF = pql_create_ldif('', '', $objects, 0, 0);
else
$LDIF .= "\n".pql_create_ldif('', '', $objects, 0, 0);
}
} elseif($_REQUEST["scope"] == "base") {
// Get the non-operational attributes
$objects1 = $_pql->search($_REQUEST["dn"], pql_get_define("PQL_ATTR_OBJECTCLASS").'=*', "BASE", 0, 0, 1);
if($_REQUEST["operationals"]) {
// Get the operational attributes
$objects2 = $_pql->search($_REQUEST["dn"], pql_get_define("PQL_ATTR_OBJECTCLASS").'=*', "BASE", 0,
array('structuralObjectClass', 'entryUUID', 'creatorsName', 'createTimestamp', 'OpenLDAPaci', 'entryCSN', 'modifiersName',
'modifyTimestamp', 'subschemaSubentry', 'hasSubordinates', 'aci'));
// Merge the two arrays
$objects = $objects1 + $objects2;
} else
$objects = $objects1;
// Create the LDIF section for this object
$LDIF = pql_create_ldif('', '', $objects, 0, 0);
}
if(!empty($LDIF)) {
if($_REQUEST["output"] == "file") {
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="phpQLAdmin.ldif"');
header("Content-Length: ".(string)(strlen($LDIF)));
header('Content-Transfer-Encoding: binary');
print $LDIF;
} else {
?>
<?php echo pql_complete_constant($LANG->_('Dumping DN %dn% with search scope \b%scope%\B'), array('dn' => urldecode($_REQUEST["dn"]), 'scope' => $_REQUEST["scope"]))?>
<pre>
----- s n i p -----
<?php echo $LDIF?>
----- s n i p -----
</pre>
<?php
}
}
}
/*
* Local variables:
* mode: php
* mode: font-lock
* tab-width: 4
* End:
*/
?>