コード例 #1
0
ファイル: Ldap.php プロジェクト: jubinpatel/horde
 /**
  * Save an extension to the LDAP tree
  *
  * @param string $account Account to which the user should be added
  *
  * @param string $extension Extension to be saved
  *
  * @param array $details Phone numbers, PIN, options, etc to be saved
  *
  * @return TRUE on success, PEAR::Error object on error
  * @throws Shout_Exception
  */
 public function saveExtension($account, $extension, $details)
 {
     // Check permissions
     parent::saveExtension($account, $extension, $details);
     // FIXME: Fix and uncomment the below
     //        // Check to ensure the extension is unique within this account
     //        $filter = "(&(objectClass=AstVoicemailMailbox)(context=$account))";
     //        $reqattrs = array('dn', $ldapKey);
     //        $res = @ldap_search($this->_LDAP, $this->_params['basedn'],
     //                            $filter, $reqattrs);
     //        if ($res === false) {
     //            $msg = sprintf('LDAP Error (%s): %s', ldap_errno($this->_LDAP),
     //                                                  ldap_error($this->_LDAP));
     //            Horde::log($msg, 'ERR');
     //            throw new Shout_Exception(_("Error while searching the directory.  Details have been logged for the administrator."));
     //        }
     //        if (($res['count'] != 1) ||
     //            ($res['count'] != 0 &&
     //            !in_array($res[0][$ldapKey], $details[$appKey]))) {
     //            throw new Shout_Exception(_("Duplicate extension found.  Not saving changes."));
     //        }
     // FIXME: Quote these strings
     $uid = $extension . '@' . $account;
     $entry = array('objectClass' => array('top', 'account', 'AsteriskVoicemail', 'AsteriskUser'), 'uid' => $uid, 'cn' => $details['name'], 'AstVoicemailEmail' => $details['email'], 'AstVoicemailMailbox' => $extension, 'AstVoicemailPassword' => $details['mailboxpin'], 'AstContext' => $account);
     $rdn = 'uid=' . $uid;
     $dn = $rdn . ',' . $this->_params['basedn'];
     if (!empty($details['oldextension'])) {
         // This is a change to an existing extension
         // First, identify the DN to modify
         // FIXME: Quote these strings
         $olddn = $this->_getExtensionDn($account, $extension);
         // If the extension has changed we need to perform an object rename
         if ($extension != $details['oldextension']) {
             $res = ldap_rename($this->_LDAP, $olddn, $rdn, $this->_params['basedn'], true);
             if ($res === false) {
                 $msg = sprintf('LDAP Error (%s): %s', ldap_errno($this->_LDAP), ldap_error($this->_LDAP));
                 Horde::log($msg, 'ERR');
                 throw new Shout_Exception(_("Error while modifying the directory.  Details have been logged for the administrator."));
             }
         }
         // Now apply the changes
         // Avoid changing the objectClass, just in case
         unset($entry['objectClass']);
         $res = ldap_modify($this->_LDAP, $dn, $entry);
         if ($res === false) {
             $msg = sprintf('LDAP Error (%s): %s', ldap_errno($this->_LDAP), ldap_error($this->_LDAP));
             Horde::log($msg, 'ERR');
             throw new Shout_Exception(_("Error while modifying the directory.  Details have been logged for the administrator."));
         }
         return true;
     } else {
         // This is an add of a new extension
         $res = ldap_add($this->_LDAP, $dn, $entry);
         if ($res === false) {
             $msg = sprintf('LDAP Error (%s): %s', ldap_errno($this->_LDAP), ldap_error($this->_LDAP));
             Horde::log($msg, 'ERR');
             throw new Shout_Exception(_("Error while modifying the directory.  Details have been logged for the administrator."));
         }
         return true;
     }
     // Catch-all.  We should not get here.
     throw new Shout_Exception(_("Unspecified error."));
 }
コード例 #2
0
ファイル: Sql.php プロジェクト: jubinpatel/horde
 /**
  * Save a user to the LDAP tree
  *
  * @param string $account Account to which the user should be added
  *
  * @param string $extension Extension to be saved
  *
  * @param array $userdetails Phone numbers, PIN, options, etc to be saved
  *
  * @return TRUE on success, PEAR::Error object on error
  */
 public function saveExtension($account, $extension, $userdetails)
 {
     parent::saveExtension($account, $extension, $details);
     throw new Shout_Exception("Not implemented.");
 }