5

I get this error always

Server is unwilling to perform

and my code is the next:

   echo "Checking ...";
    $username = $_POST["username"];
    $passwd = $_POST["passwd"];
    $host              = 'myhost.co.uk'; 
    $port              = 389; 
    $dn                = 'uid='.$username.',cn=nssproxy,ou=users,dc=co,dc=uk';

   // conexion a ldap

    $conn = ldap_connect( "ldap://".$host.":389") ;

    ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
    ldap_set_option($conn, LDAP_OPT_REFERRALS, 0);

    // match de usuario y password
    $bind = ldap_bind( $conn, $dn, $password );


    if ($bind){
        echo "OK";
    }
    else {
        echo "NO OK";
    }
    echo ldap_error($conn);

Why I have this error? I'm always testing with any user, this script return same error.

Thanks in advance.

ManuParra
  • 1,471
  • 6
  • 18
  • 33

5 Answers5

6

So I searched Google for Server is unwilling to performand the first result says:

C.1.4. ldap_*: server is unwilling to perform

slapd will return an unwilling to perform error if the backend holding the target entry does not support the given operation.

The password backend is only willing to perform searches. It will return an unwilling to perform error for all other operations.

The shell backend is configurable and may support a limited subset of operations. Check for other errors indicating a shortage of resources required by the directory server. i.e. you may have a full disk etc

ldap_mod_replace() [function.ldap-mod-replace]: Modify: Server is unwilling to perform has some requirements as well

Community
  • 1
  • 1
Digital Chris
  • 6,177
  • 1
  • 20
  • 29
  • 2
    I just had a similar issue where LDAP through PHP, which was working just fine yesterday, all of a sudden stopped working today. The error I kept getting was "your browser doesn't have cookies enabled" (from MediaWiki), even though they were in deed enabled on my browser. I checked and realized my /var logical volume was 100% full. I cleared some space, restarted HTTPD, and everything was just fine. – Michael Plautz Jul 30 '15 at 21:26
0

One possibility is what I did... I misconfigured /etc/ldap.conf, and added binddn where I meant to put rootbinddn, and that caused this message.

Peter
  • 3,067
  • 2
  • 17
  • 18
0

I had this error. Ldap on virtual machine on windows server 2019 on 10.0.0.14 IP.

I managed to connect and bind successfuly, but this error occurs when ldap_add().

My solution was to check $record array parameters that i want to save.

I this set of properties work for me:

$r = ldap_add($this->LdapConn, 'CN=user 3,'.$this->Branch, array(
        'cn'            => 'user 3',
        'name'          =>  'test',
        'sn'            => 'asd',
        'instanceType'  => '4',
        'objectCategory'=> 'CN=Person,CN=Schema,CN=Configuration,DC=test-domain,DC=com',
        'mail'          => 'mai222222l@mail2.com',
        'objectclass'=>array(
            'top',
            'user',
            'person',
            'organizationalPerson'
        )
    ));

Note that ldap_add() second parameter is path (dn) to entry and this can cause problem.

Path(dn) must be current branch + entry

For me current branch was 'CN=Users,DC=test-domain,DC=com' and full path mean dn = "CN=user 3,CN=Users,DC=test-domain,DC=com"

Note that this first part cn=user 3 must be the same as in bellow array.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Jakub Ujvvary
  • 421
  • 4
  • 13
0

My distinguish names (dc) was incorrect.

Caio V.
  • 315
  • 3
  • 9
0

Hopefully this will save somebody a few hours, so here are some more possible reasons:

  1. You have suppressed the real error message of @ldap_bind. Then you realise that:
  2. the real error is: ldap_bind(): Unable to bind to server: Can't contact LDAP server. Digging further you realise that:
  3. when upgrading debian to bullseye, you need to install libldap-common package.
Razvan Grigore
  • 1,649
  • 17
  • 17