title: What does this LDAP error mean? "00000057: LdapErr: DSID-0C090B0B, comment: Error processing control, data 0, v3839"
body: <p>This against an active directory LDAP server.  The code is running on RHEL6.</p>
  <p>Code:</p>
  <pre><code>static void waitforuser ( const char * netid ) {
          LDAP *          ld              = NULL;
          char            ldapuri[]       = &quot;ldaps://windc1.iastate.edu&quot;;
          char            binddn[]        = BINDDN;
          int             msgid           = 0;
          struct berval   passwd          = { 0, NULL };
          int             protocol        = LDAP_VERSION3;
          LDAPMessage *   result          = NULL;
          LDAPMessage *   msg             = NULL;
          int             err             = 0;
          char **         refs            = NULL;
          char            base[]          = &quot;dc=iastate,dc=edu&quot;;
          int             scope           = LDAP_SCOPE_SUBORDINATE;
          char *          filter          = NULL;
          char **         attrs           = NULL;
          int             attrsonly       = 0;
          LDAPControl **  sctrls          = NULL;
          LDAPControl **  cctrls          = NULL;
          LDAPControl **  ctrls           = NULL;
          char *          matcheddn       = NULL;
          char *          text            = NULL;
          struct timeval  tv_timelimit    = { 2, 0 };
          int             sizelimit       = 0;            /* no limit */
          int             rc              = 0;
  
          rc = ldap_initialize(&amp;ld, ldapuri);
          if (rc != LDAP_SUCCESS) {
                  fprintf(stderr,
                      &quot;Could not create LDAP session handle for URI=%s (%d): %s\n&quot;,
                      ldapuri, rc, ldap_err2string(rc));
                  return;
          }
          fprintf(stderr, &quot;about to ldap_set_option(PROTOCOL_VERSION)\n&quot;);
          rc = ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &amp;protocol);
          if (rc != LDAP_SUCCESS) {
                  fprintf(stderr, &quot;Could not set LDAP_OPT_PROTOCOL_VERSION %d\n&quot;, protocol);
                  return;
          }
  
          fprintf(stderr, &quot;about to ldap_simple_bind_s\n&quot;);
          rc = ldap_simple_bind_s(ld, binddn, SHHHH);
          fprintf(stderr, &quot;ldap_simple_bind_s =&gt; %d (%s)\n&quot;, rc, ldap_err2string(rc));
  
         asprintf(&amp;filter, &quot;sAMAccountName=%s&quot;, netid);
          attrs = calloc(2, sizeof(char *));
          attrs[0] = strdup(&quot;sAMAccountName&quot;);
          attrs[1] = NULL;
          rc = ldap_search_ext(ld, base, scope, filter, attrs, attrsonly,
                  sctrls, cctrls, &amp;tv_timelimit, sizelimit, &amp;msgid);
          if (rc != LDAP_SUCCESS) {
                  fprintf(stderr, &quot;ldap_search_ext: %d (%s)\n&quot;, rc, ldap_err2string(rc));
                  return;
          }
          while ((rc = ldap_result(ld, msgid, LDAP_MSG_ONE, &amp;tv_timelimit, &amp;result)) &gt; 0) {
                  fprintf(stderr, &quot;There are %d messages\n&quot;, ldap_count_messages(ld, result));
                  for (msg = ldap_first_message(ld, result);
                       msg != NULL;
                       msg = ldap_next_message(ld, msg)) {
                          fprintf(stderr, &quot; ldap_msgtype(%p) = %d\n&quot;, msg, ldap_msgtype(msg));
                          if (ldap_msgtype(msg) == LDAP_RES_SEARCH_RESULT) {
                                  fprintf(stderr, &quot;  LDAP_RES_SEARCH_RESULT\n&quot;);
                                  rc = ldap_parse_result(ld, msg, &amp;err, &amp;matcheddn, &amp;text, &amp;refs, &amp;ctrls, 0);
                                                 fprintf(stderr, &quot;ldap_parse_result:       err: %d\n&quot;, err);
                                  if (matcheddn) fprintf(stderr, &quot;ldap_parse_result: matcheddn: '%s'\n&quot;, matcheddn);
                                                 fprintf(stderr, &quot;ldap_parse_result:      refs: %p\n&quot;, refs);
                                                 fprintf(stderr, &quot;ldap_parse_result:     ctrls: %p\n&quot;, ctrls);
                                  if (rc != LDAP_SUCCESS) {
                                          fprintf(stderr, &quot;ldap_parse_result: ERR %d (%s)\n&quot;, rc, ldap_err2string(rc));
                                  } else {
                                          fprintf(stderr, &quot;ldap_parse_result:      text: '%s'\n&quot;, text ? text : &quot;NULL!&quot;);
                                  }
                          }
                          ldap_msgfree(result);
                  }
          }
  }
  </code></pre>
  <p>Results:</p>
  <pre><code>ldap_simple_bind_s =&gt; 0 (Success)
  There are 1 messages
   ldap_msgtype(0x1e738a0) = 101
    LDAP_RES_SEARCH_RESULT
  ldap_parse_result:       err: 80
  ldap_parse_result:      refs: (nil)
  ldap_parse_result:     ctrls: (nil)
  ldap_parse_result:      text: '00000057: LdapErr: DSID-0C090B0B, comment: Error processing control, data 0, v3839'
  </code></pre>
  <p>A similar query using the ldapsearch tool works fine:</p>
  <pre><code>#!/bin/sh
  netid=&quot;john&quot;
  user=xxxxxx@iastate.edu
  passwdfile=/home/john/secret
  base=&quot;dc=iastate,dc=edu&quot;
  connect=&quot;-s sub -W -D $user -y $passwdfile -b $base -LLL -l 2 -o nettimeout=2&quot;
  url=ldaps://windc1.iastate.edu
  ldapsearch -H $url $connect sAMAccountName=$netid sAMAccountName
  </code></pre>
  <p>Results:</p>
  <pre><code>dn: CN=john,OU=Users,OU=ITS,DC=iastate,DC=edu
  sAMAccountName: john
  </code></pre>