1 |
<?php /* |
<?php /* |
2 |
LuDAP : Lightweight Users Directory Administration Protocol |
LuDAP : Lightweight Users Directory Administration Protocol |
3 |
$Id$ |
$Header$ |
4 |
------------------------------------------------------------------------ |
------------------------------------------------------------------------ |
5 |
copyright (C) 2003 mose . mose@ludap.org |
copyright (C) 2003 mose . mose@ludap.org |
6 |
copyright (C) 2001, 2002 mose, makina corpus - mose@makina-corpus.org |
copyright (C) 2001, 2002 mose, makina corpus - mose@makina-corpus.org |
19 |
the Free Software Foundation, Inc., |
the Free Software Foundation, Inc., |
20 |
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
------------------------------------------------------------------------ |
------------------------------------------------------------------------ |
|
file: ludap.lib.php |
|
|
description: storage of functions |
|
|
used in: index.php |
|
22 |
*/ |
*/ |
23 |
|
|
24 |
// writes raw logs in a plain text file |
/** |
25 |
function authlog($type) { |
* |
26 |
global $conf; |
*/ |
27 |
$log = date("Y/m/d - H:i:s")." - "; |
|
28 |
$log.= getenv('PHP_SELF')." - $type - "; |
class ludap { |
29 |
$log.= getenv('REMOTE_ADDR')." - "; |
|
30 |
$log.= getenv('HTTP_X_FORWARDED_FOR')." - "; |
var $ver = '0.5'; |
31 |
$log.= getenv('HTTP_USER_AGENT')."\n"; |
var $conf = array(); |
32 |
$fp = @fopen($conf['global']['logdir']."/.auth.log", "a+"); |
|
33 |
if ($fp) { |
function ludap($conf_file) { |
34 |
while (!flock($fp,2) and ($i < 30)) { sleep(2); $i++; } |
$confludap = new conf($conf_file); |
35 |
@fputs($fp,$log); |
$this->conf = $confludap->readconf(); |
|
flock($fp,3); |
|
|
@fclose($fp); |
|
36 |
} |
} |
|
} |
|
37 |
|
|
38 |
function readconf($file) { |
function check_ldap_ability() { |
39 |
if (!file_exists($file)) die('please create appropriate conf file'); |
if (!function_exists("ldap_connect")) { |
40 |
foreach (file($file) as $line) { |
if (!extension_loaded('ldap')) { |
41 |
$r = $s = ''; |
if (strtoupper(substr(PHP_OS, 0,3) == 'WIN')) { |
42 |
if (substr($line,0,1) != "#") { |
$dllso = "ldap.dll"; |
|
if (ereg("^\[([A-Z]+)\]",$line,$r)) { |
|
|
$var = strtolower($r[1]); |
|
|
} |
|
|
if ($var and (ereg("^([-_/ a-zA-Z0-9]+)[ \t]+:[ \t]+(.*)",$line,$s))) { |
|
|
if (strstr($s[2],"|")) { |
|
|
$parts = split("\|",$s[2]); |
|
|
$lp = trim($parts[0]); |
|
|
$xp = split(',',trim($parts[1])); |
|
|
array_unshift($xp, $lp); |
|
|
$back[$var][trim($s[1])] = $xp; |
|
43 |
} else { |
} else { |
44 |
$back[$var][trim($s[1])] = trim($s[2]); |
$dllso = "ldap.so"; |
45 |
} |
} |
46 |
|
if (!dl($dllso)) die("LDAP support not compiled in PHP, and dynamic LDAP module $ddlso unable to load."); |
47 |
|
} else { |
48 |
|
die("LDAP module found, but not working."); |
49 |
} |
} |
50 |
} |
} |
51 |
} |
} |
|
return $back; |
|
|
} |
|
52 |
|
|
53 |
function domenu($list,$it) { |
function domenu($list,$it) { |
54 |
foreach ($list as $k=>$l) { |
foreach ($list as $k=>$l) { |
55 |
if ($it == $k) { |
if ($it == $k) { |
56 |
$back.= "<option value='$k' selected>$l\n"; |
$back.= "<option value='$k' selected>$l\n"; |
57 |
} else { |
} else { |
58 |
$back.= "<option value='$k'>$l\n"; |
$back.= "<option value='$k'>$l\n"; |
59 |
} |
} |
60 |
} |
} |
61 |
return "$back"; |
return "$back"; |
62 |
} |
} |
63 |
|
|
64 |
function get_gid($uid,$attrs='') { |
function get_gid($id,$attrs='') { |
65 |
global $conn, $conf; |
global $conn, $conf; |
66 |
if (is_array($attrs)) { |
if (is_array($attrs)) { |
67 |
$i = ldap_search($conn,$conf['ludap']['groupdn'],$conf['ludap']['membattr']."=$uid",$attrs); |
$i = ldap_search($conn,$conf['ludap']['groupdn'],$conf['ludap']['membattr']."=$id",$attrs); |
68 |
} else { |
} else { |
69 |
$i = ldap_search($conn,$conf['ludap']['groupdn'],$conf['ludap']['membattr']."=$uid"); |
$i = ldap_search($conn,$conf['ludap']['groupdn'],$conf['ludap']['membattr']."=$id"); |
70 |
} |
} |
71 |
$info = ldap_get_entries($conn,$i); |
$info = ldap_get_entries($conn,$i); |
72 |
foreach ($conf[group] as $clabel=>$cbuff) { |
foreach ($conf[group] as $clabel=>$cbuff) { |
73 |
if ($cbuff[2] == 'multi') { |
if ($cbuff[2] == 'multi') { |
74 |
if ($info[0][$clabel][count]) { |
if ($info[0][$clabel][count]) { |
75 |
array_shift($info[0][$clabel]); |
array_shift($info[0][$clabel]); |
76 |
foreach ($info[0][$clabel] as $icl) { |
foreach ($info[0][$clabel] as $icl) { |
77 |
if ($cbuff[1] == 'dn') { |
if ($cbuff[1] == 'dn') { |
78 |
if (ereg("{$conf['ludap']['baseattr']}=([^,]+),{$conf['ludap']['basedn']}",$icl,$match)) { |
if (ereg("{$conf['ludap']['baseattr']}=([^,]+),{$conf['ludap']['basedn']}",$icl,$match)) { |
79 |
$fres[$clabel][] = array($conf['ludap']['baseattr'], $conf['ludap']['basedn'], utf8_decode($match[1])); |
$fres[$clabel][] = array($conf['ludap']['baseattr'], $conf['ludap']['basedn'], utf8_decode($match[1])); |
80 |
|
} |
81 |
|
} else { |
82 |
|
$fres[$clabel][] = utf8_decode($icl); |
83 |
} |
} |
|
} else { |
|
|
$fres[$clabel][] = utf8_decode($icl); |
|
84 |
} |
} |
85 |
} |
} |
86 |
|
} elseif ($cbuff[1] == 'image') { |
87 |
|
$ei = ldap_first_entry($conn, $i); |
88 |
|
$tmpimg = @ldap_get_values_len($conn,$ei,$clabel); |
89 |
|
if ($tmpimg) { |
90 |
|
$fp = fopen("tmp/$id.jpg", "w"); |
91 |
|
fwrite($fp, $tmpimg[0]); |
92 |
|
fclose($fp); |
93 |
|
$fres[$clabel] = "tmp/$id.jpg"; |
94 |
|
} |
95 |
|
/* |
96 |
|
echo "<pre>"; print_r($tmpimg); die("</pre>"); |
97 |
|
*/ |
98 |
|
} elseif ($cbuff[1] == 'dn') { |
99 |
|
$fres[$clabel] = strtok(utf8_decode($info[0][$clabel][0]),','); |
100 |
|
} else { |
101 |
|
$fres[$clabel] = utf8_decode($info[0][$clabel][0]); |
102 |
} |
} |
|
} elseif ($cbuff[1] == 'image') { |
|
|
$ei = ldap_first_entry($conn, $i); |
|
|
$tmpimg = @ldap_get_values_len($conn,$ei,$clabel); |
|
|
if ($tmpimg) { |
|
|
$fp = fopen("tmp/$uid.jpg", "w"); |
|
|
fwrite($fp, $tmpimg[0]); |
|
|
fclose($fp); |
|
|
$fres[$clabel] = "tmp/$uid.jpg"; |
|
|
} |
|
|
/* |
|
|
echo "<pre>"; print_r($tmpimg); die("</pre>"); |
|
|
*/ |
|
|
} elseif ($cbuff[1] == 'dn') { |
|
|
$fres[$clabel] = strtok(utf8_decode($info[0][$clabel][0]),','); |
|
|
} else { |
|
|
$fres[$clabel] = utf8_decode($info[0][$clabel][0]); |
|
103 |
} |
} |
104 |
|
return $fres; |
105 |
} |
} |
|
return $fres; |
|
|
} |
|
106 |
|
|
107 |
function get_uid($uid,$attrs='') { |
function get_id($id,$attrs='') { |
108 |
global $conn, $conf; |
global $conn, $conf; |
109 |
if (is_array($attrs)) { |
if (is_array($attrs)) { |
110 |
$i = ldap_search($conn,$conf['ludap']['basedn'],$conf['ludap']['baseattr']."=$uid",$attrs); |
$i = ldap_search($conn,$conf['ludap']['basedn'],$conf['ludap']['baseattr']."=$id",$attrs); |
|
} else { |
|
|
$i = ldap_search($conn,$conf['ludap']['basedn'],$conf['ludap']['baseattr']."=$uid"); |
|
|
} |
|
|
$info = ldap_get_entries($conn,$i); |
|
|
foreach ($conf[human] as $clabel=>$cbuff) { |
|
|
if ($cbuff[2] == 'multi') { |
|
|
if ($info[0][$clabel][count]) { |
|
|
array_shift($info[0][$clabel]); |
|
|
foreach ($info[0][$clabel] as $icl) { |
|
|
$fres[$clabel][] = utf8_decode($icl); |
|
|
} |
|
|
} |
|
|
} elseif ($cbuff[1] == 'image') { |
|
|
$ei = ldap_first_entry($conn, $i); |
|
|
$tmpimg = @ldap_get_values_len($conn,$ei,$clabel); |
|
|
if ($tmpimg) { |
|
|
$fp = fopen("tmp/$uid.jpg", "w"); |
|
|
fwrite($fp, $tmpimg[0]); |
|
|
fclose($fp); |
|
|
$fres[$clabel] = "tmp/$uid.jpg"; |
|
|
} |
|
|
/* |
|
|
echo "<pre>"; print_r($tmpimg); die("</pre>"); |
|
|
*/ |
|
111 |
} else { |
} else { |
112 |
$fres[$clabel] = utf8_decode($info[0][$clabel][0]); |
$i = ldap_search($conn,$conf['ludap']['basedn'],$conf['ludap']['baseattr']."=$id"); |
113 |
} |
} |
114 |
|
$info = ldap_get_entries($conn,$i); |
115 |
|
foreach ($conf[human] as $clabel=>$cbuff) { |
116 |
|
if ($cbuff[2] == 'multi') { |
117 |
|
if ($info[0][$clabel][count]) { |
118 |
|
array_shift($info[0][$clabel]); |
119 |
|
foreach ($info[0][$clabel] as $icl) { |
120 |
|
$fres[$clabel][] = utf8_decode($icl); |
121 |
|
} |
122 |
|
} |
123 |
|
} elseif ($cbuff[1] == 'image') { |
124 |
|
$ei = ldap_first_entry($conn, $i); |
125 |
|
$tmpimg = @ldap_get_values_len($conn,$ei,$clabel); |
126 |
|
if ($tmpimg) { |
127 |
|
$fp = fopen("tmp/$id.jpg", "w"); |
128 |
|
fwrite($fp, $tmpimg[0]); |
129 |
|
fclose($fp); |
130 |
|
$fres[$clabel] = "tmp/$id.jpg"; |
131 |
|
} |
132 |
|
/* |
133 |
|
echo "<pre>"; print_r($tmpimg); die("</pre>"); |
134 |
|
*/ |
135 |
|
} else { |
136 |
|
$fres[$clabel] = utf8_decode($info[0][$clabel][0]); |
137 |
|
} |
138 |
|
} |
139 |
|
return $fres; |
140 |
} |
} |
|
return $fres; |
|
|
} |
|
141 |
|
|
142 |
// ROU 20030303 récupère la liste des adresses mails |
// ROU 20030303 récupère la liste des adresses mails |
143 |
function get_mails($uid='') { |
function get_mails($id='') { |
144 |
global $conn, $conf; |
global $conn, $conf; |
145 |
$cn = $conf['ludap']['membattr']; |
$cn = $conf['ludap']['membattr']; |
146 |
if ($uid) { |
if ($id) { |
147 |
$limit = "{$conf['ludap']['membattr']}={$uid}*"; |
$limit = "{$conf['ludap']['membattr']}={$id}*"; |
148 |
} else { |
} else { |
149 |
$limit = "($cn=*)"; |
$limit = "($cn=*)"; |
|
} |
|
|
$i = ldap_search($conn,$conf['ludap']['maildn'],$conf['ludap']['membattr']."=$uid",array($conf['ludap']['mailattr'])); |
|
|
$info = ldap_get_entries($conn,$i); |
|
|
for ($x=0; $x<$info["count"]; $x++) { |
|
|
for ($y=0; $y<$info[$x][$conf['ludap']['mailattr']]['count']; $y++) { |
|
|
$f_mails[] = utf8_decode($info[$x][$conf['ludap']['mailattr']][$y]); |
|
150 |
} |
} |
151 |
|
$i = ldap_search($conn,$conf['ludap']['maildn'],$conf['ludap']['membattr']."=$id",array($conf['ludap']['mailattr'])); |
152 |
|
$info = ldap_get_entries($conn,$i); |
153 |
|
for ($x=0; $x<$info["count"]; $x++) { |
154 |
|
for ($y=0; $y<$info[$x][$conf['ludap']['mailattr']]['count']; $y++) { |
155 |
|
$f_mails[] = utf8_decode($info[$x][$conf['ludap']['mailattr']][$y]); |
156 |
|
} |
157 |
|
} |
158 |
|
return $f_mails; |
159 |
} |
} |
160 |
return $f_mails; |
// ROU 20030303 |
|
} |
|
|
// ROU 20030303 |
|
161 |
|
|
162 |
function get_groups($uid='') { |
function get_groups($id='') { |
163 |
global $conn, $conf; |
global $conn, $conf; |
164 |
$cn = $conf['ludap']['membattr']; |
$cn = $conf['ludap']['membattr']; |
165 |
if ($uid) { |
if ($id) { |
166 |
$limit = "{$conf['ludap']['groupattr']}={$conf['ludap']['baseattr']}={$uid},{$conf['ludap']['basedn']}"; |
$limit = $conf['ludap']['groupattr']."=".$id.", ".$conf['ludap']['basedn']; |
167 |
} else { |
} else { |
168 |
$limit = "($cn=*)"; |
$limit = "($cn=*)"; |
169 |
} |
} |
170 |
$i = ldap_search($conn,$conf['ludap']['groupdn'],$limit,array($cn)); |
$i = ldap_search($conn,$conf['ludap']['groupdn'],$limit,array($cn)); |
171 |
$info = ldap_get_entries($conn,$i); |
$info = ldap_get_entries($conn,$i); |
172 |
for ($x=0; $x<$info["count"]; $x++) { |
for ($x=0; $x<$info["count"]; $x++) { |
173 |
$f_gps[] = utf8_decode($info[$x][$cn][0]); |
$f_gps[] = utf8_decode($info[$x][$cn][0]); |
174 |
|
} |
175 |
|
return $f_gps; |
176 |
} |
} |
|
return $f_gps; |
|
|
} |
|
177 |
|
|
178 |
function defaultdir($uid) { |
function del_groups($id) { |
179 |
return "/home/$uid"; |
|
180 |
} |
} |
181 |
|
|
182 |
|
function defaultdir($id) { |
183 |
|
return "/home/$id"; |
184 |
|
} |
185 |
|
|
186 |
function increment($attr) { |
function increment($attr) { |
187 |
global $conn, $conf; |
global $conn, $conf; |
188 |
$i = ldap_search($conn,$conf['ludap']['basedn'],"uid=*",array($attr)); |
$i = ldap_search($conn,$conf['ludap']['basedn'],$conf['ludap']['baseattr']."=*",array($attr)); |
189 |
$info = ldap_get_entries($conn,$i); |
$info = ldap_get_entries($conn,$i); |
190 |
$max = 0; |
$max = 0; |
191 |
for ($x=0; $x<$info["count"]; $x++) { |
for ($x=0; $x<$info["count"]; $x++) { |
192 |
if ($info[$x][$attr][0] > $max) { |
if ($info[$x][$attr][0] > $max) { |
193 |
$max = $info[$x][$attr][0]; |
$max = $info[$x][$attr][0]; |
194 |
|
} |
195 |
} |
} |
196 |
|
$max++; |
197 |
|
return $max; |
198 |
} |
} |
|
$max++; |
|
|
return $max; |
|
|
} |
|
199 |
|
|
200 |
function write_uid($fes) { |
function write_id($fes) { |
201 |
global $conn, $conf; |
global $conn, $conf; |
202 |
$in[objectclass] = split(',',$conf[ludap][baseobj]); |
$in[objectclass] = split(',',$conf[ludap][baseobj]); |
203 |
foreach ($conf[human] as $clabel=>$cbuff) { |
foreach ($conf[human] as $clabel=>$cbuff) { |
204 |
list($cl,$ntxt,$ntype,$nfunc) = $cbuff; |
list($cl,$ntxt,$ntype,$nfunc) = $cbuff; |
205 |
if ($ntype == 'primary') { |
if ($ntype == 'primary') { |
206 |
$xres = get_uid($fes[$clabel],array($clabel)); |
$xres = get_id($fes[$clabel],array($clabel)); |
207 |
if ($xres[$clabel]) { |
if ($xres[$clabel]) { |
208 |
$output[] = "Il y a deja un $clabel nommé $fes[$clabel]"; |
$output[] = "Il y a deja un $clabel nommé $fes[$clabel]"; |
209 |
} elseif (!ereg("[_a-z0-9]{3,16}",$fes[$clabel])) { |
} elseif (!ereg("[_a-z0-9]{3,16}",$fes[$clabel])) { |
210 |
$output[] = "Probleme de syntaxe pour $clabel (".$fes[$clabel].")."; |
$output[] = "Probleme de syntaxe pour $clabel (".$fes[$clabel].")."; |
211 |
|
} else { |
212 |
|
$in[$clabel] = utf8_encode($fes[$clabel]); |
213 |
|
$primary = $clabel; |
214 |
|
$id = $fes[$clabel]; |
215 |
|
} |
216 |
|
} elseif ($ntype == 'noedit') { |
217 |
|
if ($nfunc == 'increment') { |
218 |
|
$in[$clabel] = increment($clabel); |
219 |
|
} elseif ($nfunc == 'defaultdir') { |
220 |
|
$in[$clabel] = defaultdir($fes[$primary]); |
221 |
|
} |
222 |
|
} |
223 |
|
} |
224 |
|
if (!$output) { |
225 |
|
$r = @ldap_add($conn, $conf['ludap']['baseattr'].'='.$fes[id].','.$conf['ludap']['basedn'], $in); |
226 |
|
if ($r) { |
227 |
|
return "$id CREATED."; |
228 |
} else { |
} else { |
229 |
$in[$clabel] = utf8_encode($fes[$clabel]); |
return array( "$id NOT CREATED: ".ldap_error($conn)); |
230 |
$primary = $clabel; |
} |
|
$uid = $fes[$clabel]; |
|
|
} |
|
|
} elseif ($ntype == 'noedit') { |
|
|
if ($nfunc == 'increment') { |
|
|
$in[$clabel] = increment($clabel); |
|
|
} elseif ($nfunc == 'defaultdir') { |
|
|
$in[$clabel] = defaultdir($fes[$primary]); |
|
|
} |
|
|
} |
|
|
} |
|
|
if (!$output) { |
|
|
$r = @ldap_add($conn, $conf['ludap']['baseattr'].'='.$fes[uid].','.$conf['ludap']['basedn'], $in); |
|
|
if ($r) { |
|
|
return "$uid CREATED."; |
|
231 |
} else { |
} else { |
232 |
return array( "$uid NOT CREATED: ".ldap_error($conn)); |
return $output; |
233 |
} |
} |
|
} else { |
|
|
return $output; |
|
234 |
} |
} |
|
} |
|
235 |
|
|
236 |
function write_all($fes) { |
function write_all($fes) { |
237 |
global $conn, $conf; |
global $conn, $conf; |
238 |
$prov = get_uid($fes[uid]); |
$prov = get_id($fes[id]); |
239 |
foreach ($conf[human] as $clabel=>$cbuff) { |
foreach ($conf[human] as $clabel=>$cbuff) { |
240 |
list($cl,$ntxt,$ntype,$nfunc) = $cbuff; |
list($cl,$ntxt,$ntype,$nfunc) = $cbuff; |
241 |
if ($prov[$clabel]) { |
if ($prov[$clabel]) { |
242 |
if ($prov[$clabel] != $fes[$clabel]) { |
if ($prov[$clabel] != $fes[$clabel]) { |
243 |
$vin = 'in'; |
$vin = 'in'; |
244 |
|
} else { |
245 |
|
$vin = 'vinout'; |
246 |
|
} |
247 |
|
} elseif ($fes[$clabel]) { |
248 |
|
$vin = 'inadd'; |
249 |
} else { |
} else { |
250 |
$vin = 'vinout'; |
$vin = 'vinout'; |
251 |
} |
} |
252 |
} elseif ($fes[$clabel]) { |
if ($fes[$clabel]) { |
253 |
$vin = 'inadd'; |
if ($ntxt == "text") { |
254 |
} else { |
if ($ntype == "md5") { |
255 |
$vin = 'vinout'; |
if ($fes[$clabel][1] and $fes[$clabel][2]) { |
256 |
} |
if ($fes[$clabel][1] == $fes[$clabel][2]) { |
257 |
if ($fes[$clabel]) { |
${$vin}[$clabel][0] = "{crypt}".crypt($fes[$clabel][1]); |
258 |
if ($ntxt == "text") { |
} else { |
259 |
if ($ntype == "md5") { |
$output[] = "Password don't match. "; |
260 |
if ($fes[$clabel][1] and $fes[$clabel][2]) { |
} |
261 |
if ($fes[$clabel][1] == $fes[$clabel][2]) { |
} |
262 |
${$vin}[$clabel][0] = "{crypt}".crypt($fes[$clabel][1]); |
} elseif ($ntype == "multi") { |
263 |
} else { |
if (is_array($fes[$clabel])) { |
264 |
$output[] = "Password don't match. "; |
foreach ($fes[$clabel] as $frc) { |
265 |
} |
if ($frc) { |
266 |
} |
${$vin}[$clabel][] = utf8_encode($frc); |
267 |
} elseif ($ntype == "multi") { |
} |
268 |
if (is_array($fes[$clabel])) { |
} |
269 |
foreach ($fes[$clabel] as $frc) { |
} |
270 |
if ($frc) { |
} else { |
271 |
${$vin}[$clabel][] = utf8_encode($frc); |
${$vin}[$clabel] = utf8_encode($fes[$clabel]); |
272 |
} |
} |
273 |
} |
} elseif ($ntxt == 'list') { |
274 |
} |
${$vin}[$clabel] = utf8_encode($fes[$clabel]); |
275 |
} else { |
} elseif ($ntxt == 'image') { |
276 |
${$vin}[$clabel] = utf8_encode($fes[$clabel]); |
if (($fes[$clabel] == 'x') and ($prov[$clabel])) { |
277 |
} |
$indel[$clabel] = array(); |
278 |
} elseif ($ntxt == 'list') { |
unlink($prov[$clabel]); |
279 |
${$vin}[$clabel] = utf8_encode($fes[$clabel]); |
} elseif ($fes[$clabel]) { |
280 |
} elseif ($ntxt == 'image') { |
$fd = fopen($fes[$clabel],"r"); |
281 |
if (($fes[$clabel] == 'x') and ($prov[$clabel])) { |
${$vin}[$clabel] = fread($fd,filesize($fes[$clabel])); |
282 |
$indel[$clabel] = array(); |
fclose($fd); |
283 |
unlink($prov[$clabel]); |
} |
284 |
} elseif ($fes[$clabel]) { |
} |
285 |
$fd = fopen($fes[$clabel],"r"); |
} elseif (($ntype != "noedit") and ($ntxt != "image")) { |
286 |
${$vin}[$clabel] = fread($fd,filesize($fes[$clabel])); |
if ($nfunc == 'mandatory') { |
287 |
fclose($fd); |
$output[] = "Le champs $cl est obligatoire"; |
288 |
} |
} elseif ($prov[$clabel]) { |
289 |
} |
$indel[$clabel] = $prov[$clabel]; |
290 |
} elseif (($ntype != "noedit") and ($ntxt != "image")) { |
} |
291 |
if ($nfunc == 'mandatory') { |
} |
292 |
$output[] = "Le champs $cl est obligatoire"; |
} |
293 |
} elseif ($prov[$clabel]) { |
if (!$output) { |
294 |
$indel[$clabel] = $prov[$clabel]; |
if (is_array($in)) { |
295 |
} |
$r = ldap_mod_replace($conn,"{$conf['ludap']['baseattr']}={$fes['id']},{$conf['ludap']['basedn']}", $in); |
296 |
} |
if ($r) { |
297 |
} |
$outgood[] = "$dn MODIFIED. (replace pass)"; |
298 |
if (!$output) { |
} else { |
299 |
if (is_array($in)) { |
$output[] = "$dn UNCHANGED: ".ldap_error($conn); |
300 |
$r = ldap_mod_replace($conn,"{$conf['ludap']['baseattr']}={$fes['uid']},{$conf['ludap']['basedn']}", $in); |
echo "<pre>"; |
301 |
if ($r) { |
print_r(get_defined_vars()); |
302 |
$outgood[] = "$dn MODIFIED. (replace pass)"; |
echo "</pre>"; |
303 |
} else { |
die(); |
304 |
$output[] = "$dn UNCHANGED: ".ldap_error($conn); |
} |
305 |
echo "<pre>"; |
} |
306 |
print_r(get_defined_vars()); |
if (is_array($indel)) { |
307 |
echo "</pre>"; |
$r = ldap_mod_del($conn,"{$conf['ludap']['baseattr']}={$fes['id']},{$conf['ludap']['basedn']}", $indel); |
308 |
die(); |
if ($r) { |
309 |
} |
$outgood[] = "$dn MODIFIED. (del pass)"; |
310 |
} |
} else { |
311 |
if (is_array($indel)) { |
$output[] = "$dn UNCHANGED: ".ldap_error($conn); |
312 |
$r = ldap_mod_del($conn,"{$conf['ludap']['baseattr']}={$fes['uid']},{$conf['ludap']['basedn']}", $indel); |
echo "<pre>"; |
313 |
if ($r) { |
print_r(get_defined_vars()); |
314 |
$outgood[] = "$dn MODIFIED. (del pass)"; |
echo "</pre>"; |
315 |
} else { |
die(); |
316 |
$output[] = "$dn UNCHANGED: ".ldap_error($conn); |
} |
317 |
echo "<pre>"; |
} |
318 |
print_r(get_defined_vars()); |
if (is_array($inadd)) { |
319 |
echo "</pre>"; |
$r = ldap_mod_add($conn,"{$conf['ludap']['baseattr']}={$fes['id']},{$conf['ludap']['basedn']}", $inadd); |
320 |
die(); |
if ($r) { |
321 |
} |
$outgood[] = "$dn MODIFIED. (add pass)"; |
322 |
} |
} else { |
323 |
if (is_array($inadd)) { |
$output[] = "$dn UNCHANGED: ".ldap_error($conn); |
324 |
$r = ldap_mod_add($conn,"{$conf['ludap']['baseattr']}={$fes['uid']},{$conf['ludap']['basedn']}", $inadd); |
echo "<pre>"; |
325 |
if ($r) { |
print_r(get_defined_vars()); |
326 |
$outgood[] = "$dn MODIFIED. (add pass)"; |
echo "</pre>"; |
327 |
} else { |
die(); |
328 |
$output[] = "$dn UNCHANGED: ".ldap_error($conn); |
} |
329 |
echo "<pre>"; |
} |
330 |
print_r(get_defined_vars()); |
if ($output) { |
331 |
echo "</pre>"; |
return $output; |
|
die(); |
|
|
} |
|
|
} |
|
|
if ($output) { |
|
|
return $output; |
|
|
} else { |
|
|
if (is_array($outgood)) { |
|
|
return implode("<br/>",$outgood); |
|
332 |
} else { |
} else { |
333 |
return "okay okay"; |
if (is_array($outgood)) { |
334 |
|
return implode("<br/>",$outgood); |
335 |
|
} else { |
336 |
|
return "okay okay"; |
337 |
|
} |
338 |
} |
} |
339 |
} |
} else { |
340 |
} else { |
return $output; |
341 |
return $output; |
} |
342 |
} |
} |
343 |
} |
} |
344 |
?> |
?> |