2 ** Copyright 1998 - 2008 Double Precision, Inc. See COPYING for
3 ** distribution information.
7 #include "courier_auth_config.h"
17 #include "authstaticlist.h"
18 #include "courierauthdebug.h"
20 static const char rcsid
[]="$Id: authldap.c,v 1.23 2008/07/10 02:43:55 mrsam Exp $";
22 extern void auth_ldap_enumerate( void(*cb_func
)(const char *name
,
31 static int auth_ldap_login(const char *service
, char *authdata
,
32 int (*callback_func
)(struct authinfo
*, void *),
35 const char *user
, *pass
;
37 if ((user
=strtok(authdata
, "\n")) == 0 ||
38 (pass
=strtok(0, "\n")) == 0)
40 DPRINTF("incomplete authentication data");
45 return authldapcommon(service
, user
, pass
, callback_func
,
49 #include "libhmac/hmac.h"
52 static int auth_ldap_cram(const char *service
,
53 const char *authtype
, char *authdata
,
54 int (*callback_func
)(struct authinfo
*, void *),
57 struct cram_callback_info cci
;
59 if (auth_get_cram(authtype
, authdata
, &cci
))
62 cci
.callback_func
=callback_func
;
63 cci
.callback_arg
=callback_arg
;
65 return authldapcommon(service
, cci
.user
, 0, &auth_cram_callback
, &cci
);
68 int auth_ldap(const char *service
, const char *authtype
, char *authdata
,
69 int (*callback_func
)(struct authinfo
*, void *),
72 if (strcmp(authtype
, AUTHTYPE_LOGIN
) == 0)
73 return (auth_ldap_login(service
, authdata
,
74 callback_func
, callback_arg
));
76 return (auth_ldap_cram(service
, authtype
, authdata
,
77 callback_func
, callback_arg
));
81 extern int auth_ldap_pre(const char *userid
, const char *service
,
82 int (*callback
)(struct authinfo
*, void *),
85 extern int auth_ldap_changepw(const char *, const char *, const char *,
88 static struct authstaticinfo authldap_info
={
98 struct authstaticinfo
*courier_authldap_init()
100 return &authldap_info
;