18 include_once (
"WHAT/Class.Provider.php");
25 $host = ($this->parms{
'host'} !=
'' ? $this->parms{
'host'} :
'127.0.0.1');
26 $port = ($this->parms{
'port'} !=
'' ? $this->parms{
'port'} :
'389');
27 $ssl = (strtolower($this->parms{
'ssl'}) ==
'y' ?
true :
false);
28 $dnbase = ($this->parms{
'dn'} !=
'' ? $this->parms{
'dn'} :
'%s');
30 $uri = sprintf(
"%s://%s:%s/", ($ssl ?
'ldaps' :
'ldap') , $host,
$port);
31 $r = ldap_connect($uri);
32 $err = ldap_get_option(
$r, LDAP_OPT_PROTOCOL_VERSION,
$ret);
34 error_log(
"[$ret] Can't establish LDAP connection : $uri");
38 $opts = $this->parms{
'options'};
39 foreach ($opts as $k => $v) {
40 ldap_set_option(
$r, $k, $v);
43 $dn = sprintf($dnbase, $username);
50 error_log(
"user=[$dn] pass=[*********] result=>" . ($b ?
"OK" :
"NOK") .
" ($err)");
72 $action->Set(
"",
$core);
73 $action->user =
new User(
"", 1);
74 $whatuser->firstname =
'--';
75 $whatuser->lastname =
'(from ldap) ' . $username;
76 $whatuser->login = $username;
77 $whatuser->password_new = uniqid(
"ldap");
78 $whatuser->iddomain =
"0";
79 $whatuser->famid =
"IUSER";
80 $err = $whatuser->Add();
81 error_log(
"What user $username added (id=" . $whatuser->id .
")");
84 return sprintf(_(
"cannot create user %s: %s") , $username,
$err);
87 include_once (
"FDL/Class.DocFam.php");
91 $du->setValue(
"us_whatid", $whatuser->id);
94 error_log(
"User $username added (id=" . $du->id .
")");
95 if ($this->parms{
'dGroup'} !=
'') {
98 $errg = $gu->addFile($du->id);
99 if ($errg ==
"") error_log(
"User $username added to group " . $this->parms{
'dGroup'});
104 sprintf(_(
"cannot create user %s: %s") , $username,
$err);
106 $core->session->close();