ldap_msgtype() function determines the type of result obtained by calling ldap_result() or ldap_search_s().
#include <ldap.h>
int ldap_msgtype( LDAPMessage *lm );
lm |
LDAP_RES_BIND indicates that the LDAPMessage structure contains the result of an LDAP bind operation. LDAP_RES_SEARCH_ENTRY indicates that the LDAPMessage structure contains an entry found during an LDAP search operation. LDAP_RES_SEARCH_REFERENCE indicates that the LDAPMessage structure contains an LDAP v3 search reference (a referral to another LDAP server) found during an LDAP search operation. LDAP_RES_SEARCH_RESULT indicates that the LDAPMessage structure contains the result of an LDAP search operation. LDAP_RES_MODIFY indicates that the LDAPMessage structure contains the result of an LDAP modify operation. LDAP_RES_ADD indicates that the LDAPMessage structure contains the result of an LDAP add operation. LDAP_RES_DELETE indicates that the LDAPMessage structure contains the result of an LDAP delete operation. LDAP_RES_MODRDN or LDAP_RES_RENAME indicates that the LDAPMessage structure contains the result of an LDAP modify DN operation. LDAP_RES_COMPARE indicates that the LDAPMessage structure contains the result of an LDAP compare operation. LDAP_RES_EXTENDED indicates that the LDAPMessage structure contains the result of an LDAP v3 extended operation. lm argument is not a pointer to a valid LDAPMessage structure. #include <stdio.h>
#include <ldap.h>
...
LDAP *ld;
LDAPMessage *result;
int msgtype;
...
/* Perform a search */
if ( ldap_search_s( ld, MY_SEARCHBASE, LDAP_SCOPE_SUBTREE, MY_FILTER,
NULL, 0, &result ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_search_s" );
return( 1 );
}
/* Get and print the message type */
msgtype = ldap_msgtype( result );
if ( msgtype != -1 ) { printf( "Message type: %d\n", msgtype );
} else { printf( "An error occurred.\n" );
}
...
ldap_msgid(), ldap_result(), ldap_search_s().
Last Updated: 10/01/98 17:06:23