]> git.sur5r.net Git - contagged/commitdiff
Automatically create a private address book on login
authorStanislav <ginermail@gmail.com>
Thu, 4 Dec 2008 14:10:21 +0000 (15:10 +0100)
committerStanislav <ginermail@gmail.com>
Thu, 4 Dec 2008 14:10:21 +0000 (15:10 +0100)
darcs-hash:20081204141021-e4d75-de37a76b7883c6935146c611ff794f5d679eeb66.gz

login.php

index 7df3d520cff04ffb03d4e27231e3bf633d88fea1..5ea09ea7379485c66b4aa5a8d0f57f7011689bef 100644 (file)
--- a/login.php
+++ b/login.php
@@ -6,9 +6,20 @@
 require_once('inc/init.php');
 
 $msg = $lang['msg_login'];
-if(isset($_REQUEST['username'])){
+if(!empty($_REQUEST['username'])){
     if (empty($_REQUEST['password'])) { $_REQUEST['password']=''; }
     if (do_ldap_bind($_REQUEST['username'],$_REQUEST['password'])){
+
+        //create private address book if simple enough
+        if(preg_match('/ou=([^,]+)$/',$conf['privatebook'],$match)){
+            $privatedn = $conf['privatebook'].', '.$_SESSION['ldapab']['binddn'];
+            if(!ldap_read($LDAP_CON,$privatedn,'')){
+                ldap_add($LDAP_CON,$privatedn,
+                         array('objectClass' => array ('organizationalUnit','top'),
+                               'ou' => $match[1]));
+            }
+        }
+
         //forward to next page
         if(!empty($_SESSION['ldapab']['lastlocation'])){
             header('Location: '.$_SESSION['ldapab']['lastlocation']);