1 | /* COPYRIGHT |
---|
2 | * Copyright (c) 2002-2002 Igor Brezac |
---|
3 | * All rights reserved. |
---|
4 | * |
---|
5 | * Redistribution and use in source and binary forms, with or without |
---|
6 | * modification, are permitted provided that the following conditions |
---|
7 | * are met: |
---|
8 | * 1. Redistributions of source code must retain the above copyright |
---|
9 | * notice, this list of conditions and the following disclaimer. |
---|
10 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
11 | * notice, this list of conditions and the following disclaimer in the |
---|
12 | * documentation and/or other materials provided with the distribution. |
---|
13 | * |
---|
14 | * THIS SOFTWARE IS PROVIDED BY IGOR BREZAC. ``AS IS'' AND ANY |
---|
15 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
---|
17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IGOR BREZAC OR |
---|
18 | * ITS EMPLOYEES OR AGENTS BE LIABLE FOR ANY DIRECT, INDIRECT, |
---|
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
---|
20 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
---|
21 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
---|
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |
---|
23 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
---|
24 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
---|
25 | * DAMAGE. |
---|
26 | * END COPYRIGHT */ |
---|
27 | |
---|
28 | #ifndef _LAK_H |
---|
29 | #define _LAK_H |
---|
30 | |
---|
31 | #include <ldap.h> |
---|
32 | #include <lber.h> |
---|
33 | |
---|
34 | #if TIME_WITH_SYS_TIME |
---|
35 | # include <sys/time.h> |
---|
36 | # include <time.h> |
---|
37 | #else |
---|
38 | # if HAVE_SYS_TIME_H |
---|
39 | # include <sys/time.h> |
---|
40 | # else |
---|
41 | # include <time.h> |
---|
42 | # endif |
---|
43 | #endif |
---|
44 | |
---|
45 | #define LAK_OK 0 |
---|
46 | #define LAK_FAIL -1 |
---|
47 | #define LAK_NOENT -2 |
---|
48 | #define LAK_NOMEM -3 |
---|
49 | |
---|
50 | #define LAK_NOT_BOUND 0 |
---|
51 | #define LAK_BIND_ANONYMOUS 1 |
---|
52 | #define LAK_BIND_AS_USER 2 |
---|
53 | |
---|
54 | #define LAK_AUTH_METHOD_BIND 0 |
---|
55 | #define LAK_AUTH_METHOD_CUSTOM 1 |
---|
56 | #define LAK_AUTH_METHOD_FASTBIND 2 |
---|
57 | |
---|
58 | typedef struct lak_conf { |
---|
59 | char *path; |
---|
60 | char *servers; |
---|
61 | char *bind_dn; |
---|
62 | char *bind_pw; |
---|
63 | int version; |
---|
64 | struct timeval timeout; |
---|
65 | int size_limit; |
---|
66 | int time_limit; |
---|
67 | int deref; |
---|
68 | int referrals; |
---|
69 | int restart; |
---|
70 | long cache_ttl; |
---|
71 | long cache_mem; |
---|
72 | int scope; |
---|
73 | char *search_base; |
---|
74 | char *filter; |
---|
75 | char auth_method; |
---|
76 | int tls_check_peer; |
---|
77 | char *tls_cacert_file; |
---|
78 | char *tls_cacert_dir; |
---|
79 | char *tls_ciphers; |
---|
80 | char *tls_cert; |
---|
81 | char *tls_key; |
---|
82 | int debug; |
---|
83 | } LAK_CONF; |
---|
84 | |
---|
85 | typedef struct lak { |
---|
86 | LDAP *ld; |
---|
87 | char bind_status; |
---|
88 | LAK_CONF *conf; |
---|
89 | } LAK; |
---|
90 | |
---|
91 | typedef struct lak_result { |
---|
92 | char *attribute; |
---|
93 | char *value; |
---|
94 | size_t len; |
---|
95 | struct lak_result *next; |
---|
96 | } LAK_RESULT; |
---|
97 | |
---|
98 | int lak_init(const char *, LAK **); |
---|
99 | void lak_close(LAK *); |
---|
100 | int lak_authenticate(LAK *, const char *, const char *, const char *); |
---|
101 | int lak_retrieve(LAK *, const char *, const char *, const char **, LAK_RESULT **); |
---|
102 | void lak_result_free(LAK_RESULT *); |
---|
103 | |
---|
104 | #endif /* _LAK_H */ |
---|