2 ** Copyright 1998 - 2008 Double Precision, Inc. See COPYING for
3 ** distribution information.
7 #include "courier_auth_config.h"
17 #include "courierauth.h"
18 #include "courierauthstaticlist.h"
19 #include "courierauthdebug.h"
20 #include "libhmac/hmac.h"
22 static int auth_ldap_login(const char *service
, char *authdata
,
23 int (*callback_func
)(struct authinfo
*, void *),
26 const char *user
, *pass
;
28 if ((user
=strtok(authdata
, "\n")) == 0 ||
29 (pass
=strtok(0, "\n")) == 0)
31 DPRINTF("incomplete authentication data");
36 return authldapcommon(service
, user
, pass
, callback_func
,
40 static int auth_ldap_cram(const char *service
,
41 const char *authtype
, char *authdata
,
42 int (*callback_func
)(struct authinfo
*, void *),
45 struct cram_callback_info cci
;
47 if (auth_get_cram(authtype
, authdata
, &cci
))
50 cci
.callback_func
=callback_func
;
51 cci
.callback_arg
=callback_arg
;
53 return authldapcommon(service
, cci
.user
, 0, &auth_cram_callback
, &cci
);
56 int auth_ldap(const char *service
, const char *authtype
, char *authdata
,
57 int (*callback_func
)(struct authinfo
*, void *),
60 if (strcmp(authtype
, AUTHTYPE_LOGIN
) == 0)
61 return (auth_ldap_login(service
, authdata
,
62 callback_func
, callback_arg
));
64 return (auth_ldap_cram(service
, authtype
, authdata
,
65 callback_func
, callback_arg
));
69 extern int auth_ldap_pre(const char *userid
, const char *service
,
70 int (*callback
)(struct authinfo
*, void *),
73 static struct authstaticinfo authldap_info
={
83 struct authstaticinfo
*courier_authldap_init()
85 return &authldap_info
;