16 include_once (
"WHAT/Class.Provider.php");
22 $host = ($this->parms{
'host'} !=
'' ? $this->parms{
'host'} :
'127.0.0.1');
23 $port = ($this->parms{
'port'} !=
'' ? $this->parms{
'port'} :
'389');
24 $ssl = (strtolower($this->parms{
'ssl'}) ==
'y' ?
true :
false);
25 $dnbase = ($this->parms{
'dn'} !=
'' ? $this->parms{
'dn'} :
'%s');
27 $uri = sprintf(
"%s://%s:%s/", ($ssl ?
'ldaps' :
'ldap') , $host, $port);
28 $r = ldap_connect($uri);
29 $err = ldap_get_option(
$r, LDAP_OPT_PROTOCOL_VERSION,
$ret);
31 error_log(
"[$ret] Can't establish LDAP connection : $uri");
35 $opts = $this->parms{
'options'};
36 foreach ($opts as $k => $v) {
37 ldap_set_option(
$r, $k, $v);
40 $dn = sprintf($dnbase, $username);
41 $b = @ldap_bind(
$r, $dn, $password);
47 error_log(
"user=[$dn] pass=[*********] result=>" . ($b ?
"OK" :
"NOK") .
" ($err)");
68 $action->Set(
"",
$core);
69 $action->user =
new Account(
"", 1);
70 $whatuser->firstname =
'--';
71 $whatuser->lastname =
'(from ldap) ' . $username;
72 $whatuser->login = $username;
73 $whatuser->password_new = uniqid(
"ldap");
74 $whatuser->famid =
"IUSER";
75 $err = $whatuser->Add();
76 error_log(
"What user $username added (id=" . $whatuser->id .
")");
79 return sprintf(_(
"cannot create user %s: %s") , $username,
$err);
82 include_once (
"FDL/Class.DocFam.php");
86 $du->setValue(
"us_whatid", $whatuser->id);
89 error_log(
"User $username added (id=" . $du->id .
")");
90 if ($this->parms{
'dGroup'} !=
'') {
96 $errg = $gu->addFile($du->id);
97 if ($errg ==
"") error_log(
"User $username added to group " . $this->parms{
'dGroup'});
102 sprintf(_(
"cannot create user %s: %s") , $username,
$err);
104 $core->session->close();
initializeUser(&$whatuser, $username, $password)
new_Doc($dbaccess, $id= '', $latest=false)
if($file) if($subject==""&&$file) if($subject=="") $err
validateCredential($username, $password)