Adldap\Connections\Provider::auth PHP 메소드

auth() 공개 메소드

public auth ( )
    public function auth()
    {
        return $this->getGuard();
    }

Usage Example

 /**
  * Connect and bind to ldap server
  * @throws \Adldap\Exceptions\Auth\BindException
  */
 public function connect()
 {
     if ($this->useSsl && $this->useTls) {
         // Prefer TLS over SSL
         $this->useSsl = false;
     }
     /*
      * Initialize provider with configuration
      */
     $schema = new OpenLDAP();
     $this->ldapProvider = new Provider(['base_dn' => $this->baseDn, 'domain_controllers' => [$this->host], 'port' => $this->port, 'admin_username' => $this->adminUsername, 'admin_password' => $this->adminPassword, 'use_ssl' => $this->useSsl, 'use_tls' => $this->useTls], null, $schema);
     $this->ldapClient = new Adldap();
     $this->ldapClient->addProvider('default', $this->ldapProvider);
     try {
         $this->ldapClient->connect('default');
         $this->ldapProvider->auth()->bindAsAdministrator();
     } catch (BindException $e) {
         throw $e;
     }
 }