1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #ifndef LDAP_AUTH_H
30 #define LDAP_AUTH_H
31
32 #include "../public/auth.h"
33 #include <sys/types.h>
34 #include <ldap.h>
35 #include <cx/map.h>
36
37 #include "config.h"
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 typedef struct ldap_auth_db LDAPAuthDB;
44 typedef struct ldap_config LDAPConfig;
45 typedef struct ldap_user LDAPUser;
46 typedef struct ldap_group LDAPGroup;
47 typedef struct ldap_member LDAPMember;
48 typedef struct ldap_group_cache LDAPGroupCache;
49
50
51
52
53
54
55
56
57 enum WSLdapGroupMemberType {
58
59
60
61
62
63 WS_LDAP_GROUP_MEMBER_DN =
0,
64
65
66
67
68
69
70 WS_LDAP_GROUP_MEMBER_UID
71 };
72
73 struct ldap_config {
74
75
76
77 const char *resource;
78
79
80
81
82 const char *basedn;
83
84
85
86
87 const char *binddn;
88
89
90
91
92 const char *bindpw;
93
94
95
96
97
98
99 const char *userSearchFilter;
100
101
102
103
104 cxstring *uidAttributes;
105
106
107
108
109 size_t numUidAttributes;
110
111
112
113
114 const char *groupSearchFilter;
115
116
117
118
119 cxstring *memberAttributes;
120
121
122
123
124 size_t numMemberAttributes;
125
126
127
128
129 enum WSLdapGroupMemberType groupMemberType;
130
131
132
133
134 WSBool enableGroups;
135
136
137
138
139 WSBool userNameIsDN;
140 };
141
142 struct ldap_group_cache {
143 LDAPGroup *first;
144 LDAPGroup *last;
145 CxMap *map;
146 };
147
148 struct ldap_auth_db {
149 AuthDB authdb;
150 LDAPConfig config;
151 LDAPGroupCache groups;
152 };
153
154 struct ldap_user {
155 User user;
156 LDAPAuthDB *authdb;
157 LDAP *ldap;
158 Session *sn;
159 Request *rq;
160 char *userdn;
161 char *uid_attr;
162 int uid;
163 int gid;
164 };
165
166 struct ldap_member {
167 char *name;
168 int uid;
169 };
170
171 struct ldap_group {
172 char *name;
173 char *dn;
174 CxMap *members;
175 time_t update;
176 };
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202 AuthDB* create_ldap_authdb(ServerConfiguration *cfg,
const char *name, ConfigNode *node);
203
204 LDAP* get_ldap_session(Session *sn, Request *rq, LDAPAuthDB *authdb);
205
206 User* ldap_get_user(AuthDB *sb, Session *sn, Request *rq,
const char *username);
207
208 LDAPGroup* ldap_get_group(Session *sn, Request *rq, LDAPAuthDB *authdb,
const char *group);
209
210 int ldap_user_verify_password(User *user,
const char *password);
211 int ldap_user_check_group(User *user,
const char *group);
212 void ldap_user_free(User *user);
213
214 #ifdef __cplusplus
215 }
216 #endif
217
218 #endif
219
220