Example #1
0
 /**
  * Constructor.
  *
  * @param Adldap $adldap
  */
 public function __construct(Adldap $adldap)
 {
     $this->adldap = $adldap;
     $connection = $adldap->getConnection();
     if ($connection) {
         $this->connection = $connection;
     }
 }
 /**
  * Register the service provider.
  */
 public function register()
 {
     // Bind the Adldap instance to the IoC
     $this->app->bind('adldap', function () {
         $config = $this->app['config'];
         $settings = $config->get('adldap');
         // Verify configuration.
         if (is_null($settings)) {
             $message = 'Adldap configuration could not be found. Try re-publishing using `php artisan vendor:publish --tag="adldap"`.';
             throw new ConfigurationMissingException($message);
         }
         // Create a new Adldap instance.
         $ad = new Adldap($settings['connection_settings'], new $settings['connection'](), $settings['auto_connect']);
         if ($config->get('app.debug')) {
             // If the application is set to debug mode, we'll display LDAP error messages.
             $ad->getConnection()->showErrors();
         }
         return $ad;
     });
     // Bind the Adldap contract to the Adldap object
     // in the IoC for dependency injection.
     $this->app->bind('Adldap\\Contracts\\Adldap', 'adldap');
 }
Example #3
0
 /**
  * @return bool
  */
 public function isConnectedToLdap()
 {
     return $this->_ldap->getConnection()->isBound();
 }
 /**
  * Logs the last LDAP error if it is not "Success".
  *
  * @param array $adldap   The instance of the adLDAP object to check for
  *                        error.
  */
 private function handleLDAPError(\Adldap\Adldap $adldap)
 {
     if (false != $adldap) {
         // May be helpful for finding out what and why went wrong.
         $adLDAPError = $adldap->getConnection()->getLastError();
         if ("Success" != $adLDAPError) {
             Log::error('Problem with LDAP:' . $adLDAPError);
         }
     }
 }