Back to index

courier  0.68.2
libldapsearch.h
Go to the documentation of this file.
00001 /*
00002 ** Copyright 2006, Double Precision Inc.
00003 **
00004 */
00005 
00006 #ifndef ldapsearch_h
00007 #define ldapsearch_h
00008 
00009 #ifdef  __cplusplus
00010 extern "C" {
00011 #endif
00012 
00013 /*
00014 ** Encapsulate interface for search address book in LDAP
00015 */
00016 
00017 #include "config.h"
00018 #if HAVE_LBER_H
00019 #include <lber.h>
00020 #endif
00021 #include <ldap.h>
00022 #include <stdio.h>
00023 
00024 struct ldapsearch {
00025 
00026        LDAP *handle;
00027 
00028        char *base;   /* Saved base of the search */
00029 };
00030 
00031 /*
00032 ** Allocate and deallocate the ldapsearch struct.
00033 */
00034 
00035 struct ldapsearch *l_search_alloc(const char *host,
00036                               int port,
00037                               const char *userid,
00038                               const char *password,
00039                               const char *base);
00040 /* base - the starting point of the search in the LDAP tree */
00041 
00042 void l_search_free(struct ldapsearch *s);
00043 
00044 /*
00045 ** Search the address book, and invoke the callback function for each
00046 ** match found.  The callback function receives the name & address of the
00047 ** found entry.  'exact_match' is nonzero if the lookupkey matched on of the
00048 ** LDAP attributes.
00049 **
00050 ** The callback function must return zero.   A non-zero return stops the
00051 ** search.
00052 */
00053 
00054 int l_search_do(struct ldapsearch *s,
00055               const char *lookupkey,
00056 
00057               int (*callback_func)(const char *utf8_name,
00058                                  const char *address,
00059                                  void *callback_arg),
00060               void *callback_arg);
00061 
00062 /*
00063 ** Ping the LDAP server (makes sure that host/port were valid, because
00064 ** any connection attempt is deferred).
00065 */
00066 
00067 int l_search_ping(struct ldapsearch *s);
00068 
00069 #ifdef  __cplusplus
00070 }
00071 #endif
00072 
00073 #endif