ldap_errno example


    public function bind(string $dn = null, #[\SensitiveParameter] string $password = null)     {
        if (!$this->connection) {
            $this->connect();
        }

        if (false === @ldap_bind($this->connection, $dn$password)) {
            $error = ldap_error($this->connection);
            switch (ldap_errno($this->connection)) {
                case self::LDAP_INVALID_CREDENTIALS:
                    throw new InvalidCredentialsException($error);
                case self::LDAP_TIMEOUT:
                    throw new ConnectionTimeoutException($error);
                case self::LDAP_ALREADY_EXISTS:
                    throw new AlreadyExistsException($error);
            }
            throw new ConnectionException($error);
        }

        $this->bound = true;
    }
if ($pageControl) {
                    $this->controlPagedResult($pageSize, true, $cookie);
                }
                $sizeLimit = $itemsLeft;
                if ($pageSize > 0 && $sizeLimit >= $pageSize) {
                    $sizeLimit = 0;
                }
                $search = @$func($con$this->dn, $this->query, $this->options['filter']$this->options['attrsOnly']$sizeLimit$this->options['timeout']$this->options['deref']$this->serverctrls);

                if (false === $search) {
                    $ldapError = '';
                    if ($errno = ldap_errno($con)) {
                        $ldapError = sprintf(' LDAP error was [%d] %s', $errnoldap_error($con));
                    }
                    if ($pageControl) {
                        $this->resetPagination();
                    }

                    throw new LdapException(sprintf('Could not complete search with dn "%s", query "%s" and filters "%s".%s.', $this->dn, $this->query, implode(',', $this->options['filter'])$ldapError));
                }

                $this->results[] = $search;
                $itemsLeft -= min($itemsLeft$pageSize);

                
 {
    }

    /** * @return $this */
    public function add(Entry $entry)
    {
        $con = $this->getConnectionResource();

        if (!@ldap_add($con$entry->getDn()$entry->getAttributes())) {
            throw new LdapException(sprintf('Could not add entry "%s": ', $entry->getDn()).ldap_error($con)ldap_errno($con));
        }

        return $this;
    }

    /** * @return $this */
    public function update(Entry $entry)
    {
        $con = $this->getConnectionResource();

        
Home | Imprint | This part of the site doesn't use cookies.