26 #define LOG_PREFIX "ldap_sync_ad"
29 #include <freeradius-devel/util/debug.h>
59 LDAPControl ctrl = {0}, ctrl2 = {0}, *ctrls[3] = { &ctrl, &ctrl2, NULL };
64 char const *filter = NULL;
86 memcpy(&ctrl.ldctl_oid, ¬ify_oid,
sizeof(ctrl.ldctl_oid));
87 ctrl.ldctl_value.bv_len = 0;
88 ctrl.ldctl_value.bv_val = NULL;
89 ctrl.ldctl_iscritical = 1;
95 memcpy(&ctrl2.ldctl_oid, &deleted_oid,
sizeof(ctrl2.ldctl_oid));
96 ctrl2.ldctl_value.bv_len = 0;
97 ctrl2.ldctl_value.bv_val = NULL;
98 ctrl2.ldctl_iscritical = 1;
100 ctrl2.ldctl_iscritical = 1;
108 DEBUG2(
"LDAP filter %s does not match Active Directory requirements, parsing for local filtering.",
110 filter =
"(objectClass=*)";
133 filter ? filter :
config->filter,
config->attrs, ctrls, NULL);
138 ERROR(
"Duplicate sync (msgid %i)", sync->
msgid);
142 DEBUG3(
"Sync created with base dn \"%s\", filter \"%s\", msgid %i",
173 int count, i, ret = 0;
175 struct berval **values;
186 DEBUG2(
"Discarding packet which fails LDAP filter");
195 values = ldap_get_values_len(sync->
conn->
handle,
msg,
"isDeleted");
196 count = ldap_count_values_len(values);
197 for (i = 0; i <
count; i++) {
198 if ((values[i]->bv_len == 4) && (strncmp(values[i]->bv_val,
"TRUE", 4) == 0)) {
203 ldap_value_free_len(values);
static int active_directory_sync_attr_add(char const *attr, void *uctx)
int active_directory_sync_state_init(fr_ldap_connection_t *conn, size_t sync_no, proto_ldap_sync_t const *inst, UNUSED uint8_t const *cookie)
Allocate a sync state structure and issue the search.
int active_directory_sync_search_entry(sync_state_t *sync, LDAPMessage *msg, UNUSED LDAPControl **ctrls)
Handle a LDAP_RES_SEARCH_ENTRY (SearchResultEntry) response.
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
#define USES_APPLE_DEPRECATED_API
Common header for all CONF_* types.
CONF_PAIR * cf_pair_find(CONF_SECTION const *cs, char const *attr)
Search for a CONF_PAIR with a specific name.
#define cf_log_err(_cf, _fmt,...)
fr_dcursor_eval_t void const * uctx
unlang_interpret_t * unlang_interpret_get_thread_default(void)
Get the default interpreter for this thread.
fr_slen_t fr_ldap_filter_parse(TALLOC_CTX *ctx, fr_dlist_head_t **root, fr_sbuff_t *filter, filter_attr_check_t attr_check, void *uctx)
Parse an LDAP filter into its component nodes.
#define LDAP_SERVER_NOTIFICATION_OID
OID of Active Directory control for.
LDAP * handle
libldap handle.
bool fr_ldap_filter_eval(fr_dlist_head_t *root, fr_ldap_connection_t *conn, LDAPMessage *msg)
Evaluate an LDAP filter.
#define LDAP_SERVER_SHOW_DELETED_OID
OID of Active Directory control which.
void * uctx
User data associated with the handle.
fr_ldap_rcode_t
Codes returned by fr_ldap internal functions.
@ LDAP_PROC_SUCCESS
Operation was successful.
Tracks the state of a libldap connection handle.
fr_ldap_rcode_t fr_ldap_search_async(int *msgid, request_t *request, fr_ldap_connection_t *pconn, char const *dn, int scope, char const *filter, char const *const *attrs, LDAPControl **serverctrls, LDAPControl **clientctrls)
Search for something in the LDAP directory.
#define EMARKER(_str, _marker_idx, _marker)
int strcasecmp(char *s1, char *s2)
static const conf_parser_t config[]
int ldap_sync_conf_attr_add(sync_config_t *config, char const *attr)
Check if an attribute is in the config list and add if not present.
char const * filter
Filter to retrieve only user objects.
sync_op_t
Operations to perform on entries.
@ SYNC_OP_MODIFY
Entry should be updated in our copy.
@ SYNC_OP_DELETE
Entry should be deleted from our copy.
char const * base_dn
DN to search for users under.
CONF_SECTION * cs
Config section where this sync was defined.
An instance of a proto_ldap_sync listen section.
Areas of the directory to receive notifications for.
int ldap_sync_entry_send(sync_state_t *sync, uint8_t const uuid[SYNC_UUID_LENGTH], struct berval *orig_dn, LDAPMessage *msg, sync_op_t op)
Enqueue a new entry change packet.
sync_state_t * sync_state_alloc(TALLOC_CTX *ctx, fr_ldap_connection_t *conn, proto_ldap_sync_t const *inst, size_t sync_no, sync_config_t const *config)
Allocate a sync state.
int8_t sync_state_cmp(void const *one, void const *two)
Compare two sync state structures on msgid.
fr_dlist_head_t * filter
Parsed filter to be applied on the network side before passing packets to the worker.
int msgid
The unique identifier for this sync session.
sync_config_t const * config
Configuration for this sync.
fr_ldap_connection_t * conn
Connection the sync is running on.
fr_pair_list_t trigger_args
Arguments to make available in triggers.
State of an individual sync.
#define fr_rb_inline_talloc_alloc(_ctx, _type, _field, _data_cmp, _data_free)
Allocs a red black that verifies elements are of a specific talloc type.
bool fr_rb_insert(fr_rb_tree_t *tree, void const *data)
The main red black tree structure.
#define FR_SBUFF_IN(_start, _len_or_end)
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
eap_aka_sim_process_conf_t * inst
int trigger_exec(unlang_interpret_t *intp, CONF_SECTION const *cs, char const *name, bool rate_limit, fr_pair_list_t *args)
Execute a trigger - call an executable to process an event.
char const * fr_strerror(void)
Get the last library error.