Platform
3.1
PHP API documentation
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Pages
usercard_ldapinit.php
Go to the documentation of this file.
1
<?php
2
/*
3
* @author Anakeen
4
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5
* @package FDL
6
*/
7
/**
8
* Initiate LDAP database
9
*
10
* @author Anakeen 2000
11
* @version $Id: usercard_ldapinit.php,v 1.18 2007/03/26 14:09:35 eric Exp $
12
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13
* @package FDL
14
* @subpackage
15
*/
16
/**
17
*/
18
// remove all tempory doc and orphelines values
19
include_once (
"FDL/Class.Doc.php"
);
20
include_once (
"FDL/Lib.Dir.php"
);
21
22
define(
"SKIPCOLOR"
,
'[1;31;40m'
);
23
define(
"UPDTCOLOR"
,
'[1;32;40m'
);
24
define(
"STOPCOLOR"
,
'[0m'
);
25
26
$clean
= (
GetHttpVars
(
"clean"
,
"no"
) ==
"yes"
);
// clean databases option
27
$appl
=
new
Application
();
28
$appl
->Set(
"USERCARD"
,
$core
);
29
30
if
(
$action
->GetParam(
"LDAP_ENABLED"
,
"no"
) !=
"yes"
) {
31
$err
=
"LDAP disabled : do nothing ; modify LDAP_ENABLED parameter if you want update LDAP usercard"
;
32
print
$err
;
33
wbar
(0, 0, $err);
34
return
true
;
35
}
36
$dbaccess
=
$appl
->GetParam(
"FREEDOM_DB"
);
37
if
(
$dbaccess
==
""
) {
38
$err
=
"Database not found : param FREEDOM_DB"
;
39
print
$err
;
40
wbar
(0, 0, $err);
41
return
true
;
42
}
43
44
$ldaphost
=
$action
->GetParam(
"LDAP_SERVEUR"
,
"localhost"
);
45
$ldappw
=
$action
->GetParam(
"LDAP_ROOTPW"
);
46
$ldapdn
=
$action
->GetParam(
"LDAP_ROOTDN"
);
47
$ldapr
=
$action
->GetParam(
"LDAP_ROOT"
);
48
if
(
$clean
) {
49
$msg = sprintf(_(
"delete %s on server %s...\n"
) ,
$ldapr
,
$ldaphost
);
50
print $msg;
51
wbar
(1, -1, $msg);
52
system(sprintf(
"ldapdelete -r -h %s -D %s -x -w %s %s"
, escapeshellarg(
$ldaphost
) , escapeshellarg(
$ldapdn
) , escapeshellarg(
$ldappw
) , escapeshellarg(
$ldapr
)));
53
wbar
(1, -1, _(
"LDAP cleaned"
));
54
}
55
56
$ldoc1
=
getChildDoc
(
$dbaccess
, 0, 0,
"ALL"
, array() ,
$action
->user->id,
"ITEM"
,
"USER"
);
57
$ldoc2
=
getChildDoc
(
$dbaccess
, 0, 0,
"ALL"
, array() ,
$action
->user->id,
"ITEM"
,
"IGROUP"
);
58
$ldoc
= array_merge(
$ldoc1
,
$ldoc2
);
59
$reste
=
countDocs
(
$ldoc
);
60
$total
=
$reste
;
61
reset(
$ldoc
);
62
while
(
$doc
=
getNextDoc
(
$dbaccess
,
$ldoc
)) {
63
//print $doc->title."\n";
64
// update LDAP only no private card
65
$err
=
$doc
->RefreshLdapCard();
66
if
((
$err
==
""
) && (
$err
!==
false
)) print
UPDTCOLOR
.
$reste
.
")"
.
$doc
->title .
": updated"
.
STOPCOLOR
.
"\n"
;
67
else
print
SKIPCOLOR
.
$reste
.
")"
.
$doc
->title .
": skipped : $err"
.
STOPCOLOR
.
"\n"
;
68
$reste
--;
69
70
wbar
(
$reste
,
$total
);
71
}
72
73
if
(
$fbar
) {
74
unlink(
$fbar
);
75
}
76
?>
← centre documentaire
© anakeen
- published under
CC License
-
Dynacase