Back to index

lightning-sunbird  0.9+nobinonly
Functions
compare.c File Reference
#include "examples.h"

Go to the source code of this file.

Functions

int main (int main, char **argv)

Function Documentation

int main ( int  main,
char **  argv 
)

Definition at line 50 of file compare.c.

{
    LDAP      *ld;
    int              rc;

    /* get a handle to an LDAP connection */
    if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
       perror( "ldap_init" );
       return( 1 );
    }

    /* authenticate to the directory as nobody */
    if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
       ldap_perror( ld, "ldap_simple_bind_s" );
       return( 1 );
    }

    /* compare the value "person" against the objectclass attribute */
    rc = ldap_compare_s( ld, ENTRYDN, "objectclass", "person" );
    switch ( rc ) {
    case LDAP_COMPARE_TRUE:
       printf( "The value \"person\" is contained in the objectclass "
              "attribute.\n" );
       break;
    case LDAP_COMPARE_FALSE:
       printf( "The value \"person\" is not contained in the objectclass "
              "attribute.\n" );
       break;
    default:
       ldap_perror( ld, "ldap_compare_s" );
    }

    /* compare the value "xyzzy" against the objectclass attribute */
    rc = ldap_compare_s( ld, ENTRYDN, "objectclass", "xyzzy" );
    switch ( rc ) {
    case LDAP_COMPARE_TRUE:
       printf( "The value \"xyzzy\" is contained in the objectclass "
              "attribute.\n" );
       break;
    case LDAP_COMPARE_FALSE:
       printf( "The value \"xyzzy\" is not contained in the objectclass "
              "attribute.\n" );
       break;
    default:
       ldap_perror( ld, "ldap_compare_s" );
    }

    ldap_unbind( ld );
    return( 0 );
}

Here is the call graph for this function: