2 ** Copyright 1998 - 2004 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.22 2005/03/20 19:10:30 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
,
51 #include "libhmac/hmac.h"
54 static int auth_ldap_cram(const char *service
,
55 const char *authtype
, char *authdata
,
56 int (*callback_func
)(struct authinfo
*, void *),
59 struct cram_callback_info cci
;
61 if (auth_get_cram(authtype
, authdata
, &cci
))
64 cci
.callback_func
=callback_func
;
65 cci
.callback_arg
=callback_arg
;
67 return authldapcommon(service
, cci
.user
, 0, &auth_cram_callback
, &cci
);
71 int auth_ldap(const char *service
, const char *authtype
, char *authdata
,
72 int (*callback_func
)(struct authinfo
*, void *),
75 if (strcmp(authtype
, AUTHTYPE_LOGIN
) == 0)
76 return (auth_ldap_login(service
, authdata
,
77 callback_func
, callback_arg
));
80 return (auth_ldap_cram(service
, authtype
, authdata
,
81 callback_func
, callback_arg
));
89 extern int auth_ldap_pre(const char *userid
, const char *service
,
90 int (*callback
)(struct authinfo
*, void *),
93 extern int auth_ldap_changepw(const char *, const char *, const char *,
96 static struct authstaticinfo authldap_info
={
103 auth_ldap_enumerate
};
106 struct authstaticinfo
*courier_authldap_init()
108 return &authldap_info
;