ldap-client.h revision d3be0145dff35c54c3c89c3ad3e1afd2c486a2d4
090c0a68a18125bd61e290b74f3dcd8817dab986Trond Norbye/* Called when the LDAP result has finished. The callback must verify first
090c0a68a18125bd61e290b74f3dcd8817dab986Trond Norbye if the result is valid or not by calling ldap_result_has_failed() or
090c0a68a18125bd61e290b74f3dcd8817dab986Trond Norbye ldap_result_get_error(). The result is freed automatically after this
090c0a68a18125bd61e290b74f3dcd8817dab986Trond Norbye callback finishes. */
090c0a68a18125bd61e290b74f3dcd8817dab986Trond Norbyetypedef void ldap_result_callback_t(struct ldap_result *result, void *context);
77bb616a49abcd468b37a4416385df92d1f698c6Trond Norbye unsigned int debug;
090c0a68a18125bd61e290b74f3dcd8817dab986Trond Norbye const char *const *attributes;
6336b638e9afd018de5f6c516eac4775d140fdaeJHKST unsigned int timeout_secs;
090c0a68a18125bd61e290b74f3dcd8817dab986Trond Norbye const char *attr;
ebb9f739bca3bc9382340b628554b484e4837d6aKnut Anders Hatlen/* Initialize LDAP. Returns 0 on success, or -1 and error_r if initialization
57065c0b4d57ca1e0182adda16962b22987a5b95Knut Anders Hatlen failed with the given settings. */
d5f75284ca588815c2f7de683d7ade1277418219Peter Brayint ldap_client_init(const struct ldap_client_settings *set,
ff5eba819da0cf7964d884630fb13262ef12c505Trond Norbye struct ldap_client **client_r, const char **error_r);
090c0a68a18125bd61e290b74f3dcd8817dab986Trond Norbyevoid ldap_client_deinit(struct ldap_client **client);
090c0a68a18125bd61e290b74f3dcd8817dab986Trond Norbyevoid ldap_client_switch_ioloop(struct ldap_client *client);
57065c0b4d57ca1e0182adda16962b22987a5b95Knut Anders Hatlenvoid ldap_search_start(struct ldap_client *client,
3ba66fbb56ef22f183da783a1b2718280c357a4eStanislav Kozina#define ldap_search_start(client, input, callback, context) \
3ba66fbb56ef22f183da783a1b2718280c357a4eStanislav Kozina (ldap_result_callback_t *)callback, context)
3ba66fbb56ef22f183da783a1b2718280c357a4eStanislav Kozina/* Returns TRUE if the LDAP query failed and result must not be used further. */
3ba66fbb56ef22f183da783a1b2718280c357a4eStanislav Kozinabool ldap_result_has_failed(struct ldap_result *result);
3ba66fbb56ef22f183da783a1b2718280c357a4eStanislav Kozina/* Returns the error string if the query had failed, or NULL if it hasn't. */
3ba66fbb56ef22f183da783a1b2718280c357a4eStanislav Kozinaconst char *ldap_result_get_error(struct ldap_result *result);
ff5eba819da0cf7964d884630fb13262ef12c505Trond Norbyestruct ldap_search_iterator* ldap_search_iterator_init(struct ldap_result *result);
ebb9f739bca3bc9382340b628554b484e4837d6aKnut Anders Hatlenconst struct ldap_entry *ldap_search_iterator_next(struct ldap_search_iterator *iter);
3ba66fbb56ef22f183da783a1b2718280c357a4eStanislav Kozinavoid ldap_search_iterator_deinit(struct ldap_search_iterator **iter);
04455c685e53d0a29925b147a936d0a6a30cb1dcJorgen Austvikvoid ldap_compare_start(struct ldap_client *client,
3ba66fbb56ef22f183da783a1b2718280c357a4eStanislav Kozina ldap_result_callback_t *callback, void *context);
090c0a68a18125bd61e290b74f3dcd8817dab986Trond Norbye#define ldap_compare_start(client, input, callback, context) \
ff5eba819da0cf7964d884630fb13262ef12c505Trond Norbye/* Returns TRUE if the comparison matched, FALSE if not. */
090c0a68a18125bd61e290b74f3dcd8817dab986Trond Norbyebool ldap_compare_result(struct ldap_result *result);
090c0a68a18125bd61e290b74f3dcd8817dab986Trond Norbyeconst char *ldap_entry_dn(const struct ldap_entry *entry);
d5f75284ca588815c2f7de683d7ade1277418219Peter Brayconst char *const *ldap_entry_get_attributes(const struct ldap_entry *entry);
d5f75284ca588815c2f7de683d7ade1277418219Peter Brayconst char *const *ldap_entry_get_attribute(const struct ldap_entry *entry, const char *attribute);