29 RCSID(
"$Id: 547cbf3d2d0ffb753d83eaf071c59c2d15ff559f $")
33 #include <freeradius-devel/util/debug.h>
34 #include <freeradius-devel/ldap/base.h>
37 #define NMAS_E_BASE (-1600)
39 #define NMAS_E_FRAG_FAILURE (NMAS_E_BASE-31)
40 #define NMAS_E_SYSTEM_RESOURCES (NMAS_E_BASE-34)
41 #define NMAS_E_INSUFFICIENT_MEMORY (NMAS_E_BASE-35)
42 #define NMAS_E_NOT_SUPPORTED (NMAS_E_BASE-36)
43 #define NMAS_E_INVALID_PARAMETER (NMAS_E_BASE-43)
44 #define NMAS_E_INVALID_VERSION (NMAS_E_BASE-52)
45 #define NMAS_E_ACCESS_NOT_ALLOWED (NMAS_E_BASE-59)
46 #define NMAS_E_INVALID_SPM_REQUEST (NMAS_E_BASE-97)
49 #define NMASLDAP_GET_PASSWORD_REQUEST "2.16.840.1.113719.1.39.42.100.13"
50 #define NMASLDAP_GET_PASSWORD_RESPONSE "2.16.840.1.113719.1.39.42.100.14"
52 #define NMAS_LDAP_EXT_VERSION 1
80 BerElement *request_ber = NULL;
88 if ((request_ber = ber_alloc()) == NULL) {
103 if (ber_flatten(request_ber, request_bv) < 0) {
109 if (request_ber) ber_free(request_ber, 1);
138 BerElement *reply_ber = NULL;
143 if ((reply_ber = ber_init(reply_bv)) == NULL) {
148 rc = ber_scanf(reply_ber,
"{iis}", server_version, &
err,
out, outlen);
155 if (reply_ber) ber_free(reply_ber, 1);
173 edir_ctx->
reqoid, edir_ctx->
dn, NULL, NULL);
191 char *reply_oid = NULL;
192 struct berval *reply_bv = NULL;
203 REDEBUG(
"Failed retrieving Universal Password");
239 if (
err)
goto finish;
253 RDEBUG3(
"Added eDirectory password. control.%pP",
vp);
255 RDEBUG2(
"Added eDirectory password");
262 if (reply_bv) ber_bvfree(reply_bv);
263 if (reply_oid) ldap_memfree(reply_oid);
311 .password_da = password_da
330 return "BER manipulation failed";
334 return "Insufficient memory or system resources";
337 return "Server response indicated Universal Password is not supported (missing password response OID)";
340 return "Bad arguments passed to eDir functions";
346 return "Bound user does not have sufficient rights to read the Universal Password of users";
349 return "Universal password is not enabled for the container of this user object";
352 return ldap_err2string(code);
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
@ UNLANG_ACTION_FAIL
Encountered an unexpected error.
static int const char char buffer[256]
#define USES_APPLE_DEPRECATED_API
fr_dcursor_eval_t void const * uctx
#define NMAS_E_INVALID_VERSION
static int ber_encode_request_data(char const *dn, struct berval **request_bv)
Takes the object DN and BER encodes the data into the BER value which is used as part of the request.
static unlang_action_t ldap_edir_get_password_start(UNUSED rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *uctx)
Submit LDAP extended operation to retrieve Universal Password.
#define NMAS_E_SYSTEM_RESOURCES
#define NMAS_E_FRAG_FAILURE
#define NMAS_E_ACCESS_NOT_ALLOWED
static int ber_decode_login_data(struct berval *reply_bv, int *server_version, void *out, size_t *outlen)
Converts the reply into server version and a return code.
fr_dict_attr_t const * password_da
static void ldap_edir_get_password_cancel(UNUSED request_t *request, UNUSED fr_signal_t action, void *uctx)
Cancel an in progress Universal Password lookup.
static unlang_action_t ldap_edir_get_password_resume(rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *uctx)
Handle results of retrieving Universal Password.
#define NMASLDAP_GET_PASSWORD_REQUEST
fr_ldap_thread_trunk_t * ttrunk
#define NMASLDAP_GET_PASSWORD_RESPONSE
char const * fr_ldap_edir_errstr(int code)
#define NMAS_E_INVALID_PARAMETER
#define NMAS_LDAP_EXT_VERSION
#define NMAS_E_INSUFFICIENT_MEMORY
unlang_action_t fr_ldap_edir_get_password(request_t *request, char const *dn, fr_ldap_thread_trunk_t *ttrunk, fr_dict_attr_t const *password_da)
Initiate retrieval of the universal password from Novell eDirectory.
#define NMAS_E_NOT_SUPPORTED
#define NMAS_E_INVALID_SPM_REQUEST
#define unlang_function_push(_request, _func, _repeat, _signal, _sigmask, _top_frame, _uctx)
Push a generic function onto the unlang stack.
TALLOC_CTX * unlang_interpret_frame_talloc_ctx(request_t *request)
Get a talloc_ctx which is valid only for this frame.
LDAP * handle
libldap handle.
fr_ldap_result_code_t ret
Result code.
trunk_request_t * treq
Trunk request this query is associated with.
fr_ldap_connection_t * ldap_conn
LDAP connection this query is running on.
LDAPMessage * result
Head of LDAP results list.
Thread LDAP trunk structure.
unlang_action_t fr_ldap_trunk_extended(TALLOC_CTX *ctx, fr_ldap_query_t **out, request_t *request, fr_ldap_thread_trunk_t *ttrunk, char const *reqoid, struct berval *reqdata, LDAPControl **serverctrls, LDAPControl **clientctrls)
Run an async LDAP "extended operation" query on a trunk connection.
#define RDEBUG_ENABLED3
True if request debug level 1-3 messages are enabled.
int fr_pair_value_bstrndup(fr_pair_t *vp, char const *src, size_t len, bool tainted)
Copy data into a "string" type value pair.
#define RETURN_MODULE_RCODE(_rcode)
rlm_rcode_t
Return codes indicating the result of the module call.
@ RLM_MODULE_OK
The module is OK, continue.
@ RLM_MODULE_FAIL
Module failed, don't reply.
#define pair_update_control(_attr, _da)
Return or allocate a fr_pair_t in the control list.
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
Stores an attribute, a value and various bits of other data.
void trunk_request_signal_cancel(trunk_request_t *treq)
Cancel a trunk request.
static size_t char ** out