title: Binding and Authenticating to an LDAP Server over SSL and TLS
body: <p>I am writing a simple LDAP client to connect to LDAP sever over SSL. I am using "openldap-2.4.35"</p>
  
  <p>So far I've tried to do a simple bind without any encryption mechanisms. 
  Here is the code I have tried:</p>
  
  <pre><code>#define LDAP_DEPRECATED 1
  #include&lt;stdio.h&gt;
  #include&lt;ldap.h&gt;
  
  #define HOST "ldap://192.168.1.95:389"
  #define BASEDN "cn=manager,dc=ashwin,dc=com"
  
  int main(){
      LDAP *ld;
      int rc;
  
      LDAPMessage *message;
  
      if(ldap_initialize(&amp;ld, HOST))    
      {
          perror( "ldap_initialize" );
          return( 1 );
      }
      printf("LDAP initialized\n");
  
      rc = ldap_simple_bind_s( ld, BASEDN, "secret" );
      if( rc != LDAP_SUCCESS )
      {
          fprintf(stderr, "ldap_simple_bind_s: %s\n", ldap_err2string(rc) );
          return( 1 );
      }
      printf( "Successful authentication\n" );
  
      return 0;
  }
  </code></pre>
  
  <p>This connects to LDAP and binds the user. If the <code>ldap_simple_bind_s</code> is successful then the authentication is successful. </p>
  
  <p>Is there any documentation for building LDAP client to connect to LDAP server on SSL and StartTLS?</p>