Authenticating user using LDAP from PHP

前端 未结 4 1371
礼貌的吻别
礼貌的吻别 2020-12-12 17:13

My project is to make a module enrollment system for our university. So I contacted the IT people in my university for details to authenticate the students into the system.

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-12 17:56

    you could use http://pear.php.net/package/Net_LDAP2/docs it's nice and works.

    Example of connection taken by the doc:

    // Inclusion of the Net_LDAP2 package:
    require_once 'Net/LDAP.php';
    
    // The configuration array:
    $config = array (
        'binddn'    => 'cn=admin,ou=users,dc=example,dc=org',
        'bindpw'    => 'password',
        'basedn'    => 'dc=example,dc=org',
        'host'      => 'ldap.example.org'
    );
    
    // Connecting using the configuration:
    $ldap = Net_LDAP2::connect($config);
    
    // Testing for connection error
    if (PEAR::isError($ldap)) {
        die('Could not connect to LDAP-server: '.$ldap->getMessage());
    }
    

提交回复
热议问题