当前位置: 首页>>代码示例>>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;未经允许,请勿转载。