Table of Contents | Previous | Next | Index

Netscape Directory SDK 3.0 for C Programmer’s Guide
     Chapter 18 Functions

ldap_compare_s()

Synchronously determines if an attribute of an entry contains a specified value.

Note that this is an older function that is included in the LDAP API for backward-compatibility. If you are writing a new LDAP client, use ldap_compare_ext_s() instead.

Syntax

#include <ldap.h>
int ldap_compare_s( LDAP *ld, const char *dn, const char *attr,
   const char *value );

Parameters

This function has the following parameters:

ld

Connection handle, which is a pointer to an LDAP structure containing information about the connection to the LDAP server.

dn

Distinguished name (DN) of the entry used in the comparison.

attr

Attribute type that you want to check the value against.

value

Value that you want to compare against the attribute values.

Returns

For a list of the possible result codes for an LDAP compare operation, see the result code documentation for the ldap_compare_ext_s() function.

Description

The ldap_compare_s() function compares a value with the value of an attribute in an entry.

A newer version of this function, ldap_compare_ext_s(), is available in this release of the LDAP API. ldap_compare_s() (the older version of the function) is included only for backward-compatibility. If you are writing a new LDAP client, use ldap_compare_ext_s() instead of ldap_compare_s().

If you want more information on ldap_compare_s(), refer to the LDAP C SDK 1.0 Programmer's Guide.

Example

The following section of code checks to see if Barbara Jensen has the e-mail address "bjensen@airius.com".

#include <stdio.h>
#include <ldap.h>
LDAP *ld;
char *dn = "uid=bjensen, ou=People, o=Airius.com";
int has_value;
...
has_value = ldap_compare_s( ld, dn, "mail", "bjensen@airius.com" );
switch ( has_value ) {
   case LDAP_COMPARE_TRUE:
      printf( "The mail attribute contains bjensen@airius.com.\n");
      break;
   case LDAP_COMPARE_FALSE:
      printf( "The mail attribute does not contain bjensen@airius.com.\n");
      break;
   default:
      ldap_perror( ld, "ldap_compare_s" );
      return( 1 );
}
...

See Also

ldap_compare_ext_s().


Table of Contents | Previous | Next | Index

Last Updated: 10/01/98 17:06:23