PHP code example of utbvirtual / openldapsavio

1. Go to this page and download the library: Download utbvirtual/openldapsavio library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

utbvirtual / openldapsavio example snippets




return [
    'host'      => 'ldaps://example.com',
    'rdn'       => 'ou=System,dc=example,dc=com', // rdn used by the user configured below, optional
    'version'   => '3', // LDAP protocol version (2 or 3)
    
    'basedn'    => 'ou=People,dc=example,dc=com', // basedn for users
    'login_attribute' => 'uid', // login attributes for users
];


public function createOrUpdateUser($credentials){
        $user = User::where('codigo', '=', $credentials['username'])->first();
        if (!$user) {
            $userdata = ['codigo' => $credentials['username'],
            'name' => $credentials['cn'], 'email' => $credentials['mail']];
            $user = User::create($userdata);
        }
        return $user;
}