當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ldap_add函數代碼示例

本文整理匯總了PHP中ldap_add函數的典型用法代碼示例。如果您正苦於以下問題:PHP ldap_add函數的具體用法?PHP ldap_add怎麽用?PHP ldap_add使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ldap_add函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addUser

 /**
  * Add a set of authentication credentials.
  *
  * @param string $accountName  The user sAMAccountName to find.
  * @param array $credentials   The credentials to be set.
  *
  * @throws Horde_Auth_Exception
  */
 public function addUser($accountName, $credentials)
 {
     /* Connect to the MSAD server. */
     $this->_connect();
     if (isset($credentials['ldap'])) {
         $dn = $credentials['ldap']['dn'];
     } else {
         $basedn = isset($credentials['basedn']) ? $credentials['basedn'] : $this->_params['basedn'];
         /* Set a default CN */
         $dn = 'cn=' . $accountName . ',' . $basedn;
         $entry['cn'] = $accountName;
         $entry['samaccountname'] = $accountName;
         $entry['objectclass'][0] = "top";
         $entry['objectclass'][1] = "person";
         $entry['objectclass'][2] = "organizationalPerson";
         $entry['objectclass'][3] = "user";
         $entry['description'] = isset($credentials['description']) ? $credentials['description'] : 'New horde user';
         if ($this->_params['ssl']) {
             $entry["AccountDisabled"] = false;
         }
         $entry['userPassword'] = Horde_Auth::getCryptedPassword($credentials['password'], '', $this->_params['encryption'], false);
         if (isset($this->_params['binddn'])) {
             $entry['manager'] = $this->_params['binddn'];
         }
     }
     $success = @ldap_add($this->_ds, $dn, $entry);
     if (!$success) {
         throw new Horde_Auth_Exception(sprintf(__CLASS__ . ': Unable to add user "%s". This is what the server said: ', $accountName) . ldap_error($this->_ds));
     }
     @ldap_close($this->_ds);
 }
開發者ID:raz0rsdge,項目名稱:horde,代碼行數:39,代碼來源:Msad.php

示例2: process

 function process()
 {
     print_r($this->input);
     if (ldap_add($this->ds, $this->rdn, $this->input)) {
         return true;
     }
 }
開發者ID:josephecmu,項目名稱:whois,代碼行數:7,代碼來源:ProcessLdapAdd.php

示例3: add

 /**
  * lastname (sn) is required for the "inetOrgPerson" schema
  */
 public function add(Users_Model_User $user)
 {
     $dn = 'cn=' . $user->username . ',' . $this->_ldapConfig->baseDn;
     $info = array('cn' => $user->username, 'givenName' => $user->firstname, 'sn' => $user->lastname, 'mail' => $user->email, 'userPassword' => $this->_hashPassword($user->password), 'objectclass' => 'inetOrgPerson');
     if (!@ldap_add($this->_dp, $dn, $info) && ldap_error($this->_dp) != 'Success') {
         throw new Exception('Could not add record to LDAP server: ' . ldap_error($this->_dp));
     }
 }
開發者ID:sdgdsffdsfff,項目名稱:auth-center,代碼行數:11,代碼來源:Ldap.php

示例4: prepareLDAPServer

 protected function prepareLDAPServer()
 {
     $this->nodes = array($this->createDn('ou=Node,') => array("objectClass" => "organizationalUnit", "ou" => "Node", "postalCode" => "1234"), $this->createDn('ou=Test1,ou=Node,') => array("objectClass" => "organizationalUnit", "ou" => "Test1"), $this->createDn('ou=Test2,ou=Node,') => array("objectClass" => "organizationalUnit", "ou" => "Test2"), $this->createDn('ou=Test1,') => array("objectClass" => "organizationalUnit", "ou" => "Test1", "l" => "e"), $this->createDn('ou=Test2,') => array("objectClass" => "organizationalUnit", "ou" => "Test2", "l" => "d"), $this->createDn('ou=Test3,') => array("objectClass" => "organizationalUnit", "ou" => "Test3", "l" => "c"), $this->createDn('ou=Test4,') => array("objectClass" => "organizationalUnit", "ou" => "Test4", "l" => "b"), $this->createDn('ou=Test5,') => array("objectClass" => "organizationalUnit", "ou" => "Test5", "l" => "a"));
     $ldap = $this->ldap->getResource();
     foreach ($this->nodes as $dn => $entry) {
         ldap_add($ldap, $dn, $entry);
     }
 }
開發者ID:pnaq57,項目名稱:zf2demo,代碼行數:8,代碼來源:AbstractOnlineTestCase.php

示例5: add

 /**
  * {@inheritdoc}
  */
 public function add(Entry $entry)
 {
     $con = $this->connection->getResource();
     if (!@ldap_add($con, $entry->getDn(), $entry->getAttributes())) {
         throw new LdapException(sprintf('Could not add entry "%s": %s', $entry->getDn(), ldap_error($con)));
     }
     return $this;
 }
開發者ID:Ener-Getick,項目名稱:symfony,代碼行數:11,代碼來源:EntryManager.php

示例6: addGroup

function addGroup($ds, $info)
{
    // On ajoute le nouveau groupe
    $r = ldap_add($ds, "cn=" . $info['cn'] . ",ou=groups,dc=rBOX,dc=lan", $info);
    // On affiche un message d'erreur si l'utilisateur n'a pas pu être ajouté
    if (!$r) {
        echo '<p class="center red">Le groupe n\'a pas pu être ajouté. Nous vous prions de nous excuser pour le désagrément.</p>';
        exit;
    }
}
開發者ID:hillfias,項目名稱:LDAPWebApp,代碼行數:10,代碼來源:addGroup.php

示例7: create

 public function create($attrs)
 {
     if (!isset($attrs['uid'])) {
         return false;
     }
     $entry = array_merge(['objectclass' => $this->objectclass], $attrs);
     try {
         return ldap_add($this->ds, "dc=" . $attrs['uid'] . "," . $this->dn, $entry);
     } catch (\Exception $e) {
         return false;
     }
 }
開發者ID:k1m0ch1,項目名稱:egor,代碼行數:12,代碼來源:Ldap.php

示例8: AssistedLDAPAdd

function AssistedLDAPAdd($ldapc, $newdn, $in)
{
    // Use these variables that are outside the function
    global $app_theme;
    // Add the new entry
    $r_add = ldap_add($ldapc, $newdn, $in);
    // Let's see if you could make it
    if (!$r_add) {
        echo '<div class="error">' . _("An error has ocurred trying to insert entries on the LDAP database: ") . ldap_error($ldapc) . '.<br /><br /><a href="javascript:history.back(1);">' . _("Back") . '</a></div>';
        include "../themes/{$app_theme}/footer.php";
        die;
    }
    return $r_add;
}
開發者ID:awasthi,項目名稱:aguilas,代碼行數:14,代碼來源:Functions.inc.php

示例9: ldapCreateUser

 /**
  * Create LDAP User
  * @param $userDn
  * @param $newUserInfo
  * @return mixed
  */
 public function ldapCreateUser($userDn, $newUserInfo)
 {
     // Initialiazing ldap connection
     $ldapInitialisation = $this->ldapInit();
     $issue = null;
     if ($ldapInitialisation) {
         // Creating user
         ErrorHandler::start(E_WARNING);
         $issue = ldap_add($this->ldapLinkIdentifier, $userDn, $newUserInfo);
         ErrorHandler::stop();
         // Closing ldap connection
         ldap_close($this->ldapLinkIdentifier);
     }
     return $issue;
 }
開發者ID:spirit-dev,項目名稱:dbox-user,代碼行數:21,代碼來源:LdapDriver.php

示例10: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->_prepareLdapServer();
     $this->_orgDn = $this->_createDn('ou=OrgTest,');
     $this->_newDn = $this->_createDn('ou=NewTest,');
     $this->_orgSubTreeDn = $this->_createDn('ou=OrgSubtree,');
     $this->_newSubTreeDn = $this->_createDn('ou=NewSubtree,');
     $this->_targetSubTreeDn = $this->_createDn('ou=Target,');
     $this->_nodes = array($this->_orgDn => array("objectClass" => "organizationalUnit", "ou" => "OrgTest"), $this->_orgSubTreeDn => array("objectClass" => "organizationalUnit", "ou" => "OrgSubtree"), 'ou=Subtree1,' . $this->_orgSubTreeDn => array("objectClass" => "organizationalUnit", "ou" => "Subtree1"), 'ou=Subtree11,ou=Subtree1,' . $this->_orgSubTreeDn => array("objectClass" => "organizationalUnit", "ou" => "Subtree11"), 'ou=Subtree12,ou=Subtree1,' . $this->_orgSubTreeDn => array("objectClass" => "organizationalUnit", "ou" => "Subtree12"), 'ou=Subtree13,ou=Subtree1,' . $this->_orgSubTreeDn => array("objectClass" => "organizationalUnit", "ou" => "Subtree13"), 'ou=Subtree2,' . $this->_orgSubTreeDn => array("objectClass" => "organizationalUnit", "ou" => "Subtree2"), 'ou=Subtree3,' . $this->_orgSubTreeDn => array("objectClass" => "organizationalUnit", "ou" => "Subtree3"), $this->_targetSubTreeDn => array("objectClass" => "organizationalUnit", "ou" => "Target"));
     $ldap = $this->_getLdap()->getResource();
     foreach ($this->_nodes as $dn => $entry) {
         ldap_add($ldap, $dn, $entry);
     }
 }
開發者ID:sasezaki,項目名稱:mirror-zf1-tests,代碼行數:15,代碼來源:CopyRenameTest.php

示例11: addUser

function addUser($ds, $info, $infoGroupes)
{
    // On ajoute le nouvel utilisateur
    $r = ldap_add($ds, "cn=" . $info["cn"] . ",ou=users,dc=rBOX,dc=lan", $info);
    // On affiche un message d'erreur si l'utilisateur n'a pas pu être ajouté
    if (!$r) {
        echo '<p class="center red">L\'utilisateur n\'a pas pu être ajouté. Nous vous prions de nous excuser pour le désagrément.</p>';
        exit;
    }
    $entry['memberUid'] = $info["cn"];
    $res = add2Group($ds, $entry, $infoGroupes);
    $res2 = add2OtherGroup($ds, $entry, $infoGroupes);
    if (!$res or !$res2) {
        return false;
    }
    return true;
}
開發者ID:hillfias,項目名稱:LDAPWebApp,代碼行數:17,代碼來源:addUser.php

示例12: saveNewUser

 public function saveNewUser($user)
 {
     if (!is_object($user) || !$user instanceof jAuthUserLDAP) {
         throw new jException('jelix~auth.ldap.object.user.unknown');
     }
     if (!($user->login != '')) {
         throw new jException('jelix~auth.ldap.user.login.unset');
     }
     $entries = $this->getAttributesLDAP($user);
     $connect = $this->_bindLdapUser();
     if ($connect === false) {
         return false;
     }
     $result = ldap_add($connect, $this->_buildUserDn($user->login), $entries);
     ldap_close($connect);
     return $result;
 }
開發者ID:CREASIG,項目名稱:lizmap-web-client,代碼行數:17,代碼來源:ldap.auth.php

示例13: saveNewUser

 public function saveNewUser($user)
 {
     if (!is_object($user) || !$user instanceof jAuthUserLDAP) {
         throw new jException('jelix~auth.ldap.object.user.unknown');
     }
     if (!($user->login != '')) {
         throw new jException('jelix~auth.ldap.user.login.unset');
     }
     $entries = $this->getAttributesLDAP($user);
     $connect = $this->_getLinkId();
     $result = false;
     if ($connect) {
         if (ldap_bind($connect, $this->_params['ldapUser'], $this->_params['ldapPassword'])) {
             $result = ldap_add($connect, $this->_buildUserDn($user->login), $entries);
         }
         ldap_close($connect);
     }
     return $result;
 }
開發者ID:hadrienl,項目名稱:jelix,代碼行數:19,代碼來源:ldap.auth.php

示例14: saveNewUser

 public function saveNewUser($user)
 {
     if (!is_object($user) || !$user instanceof jAuthUserLDAP) {
         throw new jException('jelix~auth.ldap.object.user.unknown');
     }
     if (!($user->login != '')) {
         throw new jException('jelix~auth.ldap.user.login.unset');
     }
     $entries = $this->getAttributesLDAP($user);
     $connect = ldap_connect($this->_params['hostname'], $this->_params['port']);
     $result = false;
     if ($connect) {
         ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
         ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
         if (ldap_bind($connect, $this->_params['ldapUser'], $this->_params['ldapPassword'])) {
             $result = ldap_add($connect, 'cn=' . $user->login . ',' . $this->_params['searchBaseDN'], $entries);
         }
         ldap_close($connect);
     }
     return $result;
 }
開發者ID:alienpham,項目名稱:helenekling,代碼行數:21,代碼來源:ldap.auth.php

示例15: registerNewUser

function registerNewUser($username, $password, $firstname, $lastname, $email, $phone, $groups)
{
    $info = array();
    $info["uid"] = $username;
    $info["userPassword"] = $password;
    $info["givenName"] = $firstname;
    $info["sn"] = $lastname;
    $info["cn"] = $firstname . $lastname;
    $info["mail"] = $email;
    $info["telephoneNumber"] = $phone;
    $info["objectClass"][0] = "top";
    $info["objectClass"][1] = "person";
    $info["objectClass"][2] = "organizationalPerson";
    $info["objectClass"][3] = "inetorgperson";
    $info["objectClass"][4] = "posixAccount";
    $info["objectClass"][5] = "inetuser";
    if (ldap_add($connection, $DN, $info) == false) {
        return false;
    }
    foreach ($groups as $group) {
        addUserToGroup($username, $group);
    }
    return true;
}
開發者ID:audunel,項目名稱:anthropos,代碼行數:24,代碼來源:user.functions.inc.php


注:本文中的ldap_add函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。