68 #define RES_CONFIG_LDAP_CONF "res_ldap.conf" 69 #define RES_CONFIG_LDAP_DEFAULT_BASEDN "asterisk" 156 if (!strcasecmp(name, var->
name))
172 for (; *somestr; somestr++) {
203 const char *attribute_name,
const char *attribute_value)
242 base_table_config =
NULL;
243 static_table_config =
NULL;
251 const char *attribute_name)
256 for (i = 0; i <
ARRAY_LEN(configs); i++) {
264 for (; attribute; attribute = attribute->
next) {
265 if (!strcasecmp(attribute_name, attribute->
name)) {
266 return attribute->
value;
271 return attribute_name;
279 const char *attribute_name)
284 for (i = 0; i <
ARRAY_LEN(configs); i++) {
292 for (; attribute; attribute = attribute->
next) {
293 if (strcasecmp(attribute_name, attribute->
value) == 0) {
294 return attribute->
name;
299 return attribute_name;
307 LDAPMessage *ldap_entry)
309 BerElement *ber =
NULL;
313 int is_delimited = 0;
316 char *ldap_attribute_name;
317 struct berval *
value;
320 ldap_attribute_name = ldap_first_attribute(
ldapConn, ldap_entry, &ber);
322 while (ldap_attribute_name) {
325 int is_realmed_password_attribute = strcasecmp(attribute_name,
"md5secret") == 0;
327 values = ldap_get_values_len(
ldapConn, ldap_entry, ldap_attribute_name);
332 for (v = values; *v; v++) {
334 valptr = value->bv_val;
335 ast_debug(2,
"attribute_name: %s LDAP value: %s\n", attribute_name, valptr);
336 if (is_realmed_password_attribute) {
337 if (!strncasecmp(valptr,
"{md5}", 5)) {
349 if (valptr[i] ==
';') {
376 ldap_value_free_len(values);
378 ldap_memfree(ldap_attribute_name);
379 ldap_attribute_name = ldap_next_attribute(
ldapConn, ldap_entry, ber);
393 LDAPMessage *ldap_result_msg,
unsigned int *entries_count_ptr)
399 LDAPMessage *ldap_entry =
NULL;
400 BerElement *ber =
NULL;
403 int is_delimited = 0;
404 char *delim_value =
NULL;
405 int delim_tot_count = 0;
410 ldap_entry = ldap_first_entry(
ldapConn, ldap_result_msg);
412 for (tot_count = 0; ldap_entry; tot_count++) {
415 ldap_entry = ldap_next_entry(
ldapConn, ldap_entry);
419 if (entries_count_ptr) {
420 *entries_count_ptr = tot_count;
431 ldap_entry = ldap_first_entry(
ldapConn, ldap_result_msg);
437 for (entry_index = 0; ldap_entry; ) {
446 char *ldap_attribute_name = ldap_first_attribute(
ldapConn, ldap_entry, &ber);
447 struct berval *
value;
448 while (ldap_attribute_name) {
450 int is_realmed_password_attribute = strcasecmp(attribute_name,
"md5secret") == 0;
453 values = ldap_get_values_len(
ldapConn, ldap_entry, ldap_attribute_name);
458 for (v = values; *v; v++) {
460 valptr = value->bv_val;
461 if (is_realmed_password_attribute) {
462 if (strncasecmp(valptr,
"{md5}", 5) == 0) {
468 if (delim_value ==
NULL && !is_realmed_password_attribute
469 && (static_table_config != table_config || strcmp(attribute_name,
"variable_value") == 0)) {
474 ast_debug(4,
"is delimited %d times: %s\n", delim_tot_count, delim_value);
479 if (is_delimited != 0 && !is_realmed_password_attribute
480 && (static_table_config != table_config || strcmp(attribute_name,
"variable_value") == 0) ) {
484 ast_debug(4,
"DELIM pos: %d i: %d\n", pos, i);
485 if (delim_value[i] ==
';') {
486 delim_value[i] =
'\0';
488 ast_debug(2,
"DELIM - attribute_name: %s value: %s pos: %d\n", attribute_name, &delim_value[pos], pos);
500 if (static_table_config == table_config) {
506 ast_debug(4,
"DELIM pos: %d i: %d delim_count: %d\n", pos, i, delim_count);
508 ast_debug(4,
"DELIM - attribute_name: %s value: %s pos: %d\n", attribute_name, &delim_value[pos], pos);
524 ast_debug(4,
"DELIM pos: %d i: %d\n", pos, i);
531 ast_debug(2,
"attribute_name: %s value: %s\n", attribute_name, valptr);
544 ldap_value_free_len(values);
546 ldap_memfree(ldap_attribute_name);
547 ldap_attribute_name = ldap_next_attribute(
ldapConn, ldap_entry, ber);
550 if (static_table_config == table_config) {
554 if (tmpdebug && tmpdebug2) {
558 vars[entry_index++] =
var;
563 }
while (delim_count <= delim_tot_count && static_table_config == table_config);
565 if (static_table_config != table_config) {
566 ast_debug(3,
"Added to vars - non static\n");
568 vars[entry_index++] =
var;
571 ldap_entry = ldap_next_entry(
ldapConn, ldap_entry);
582 return (err == LDAP_SERVER_DOWN || err == LDAP_TIMEOUT || err == LDAP_CONNECT_ERROR);
602 LDAPMessage *ldap_result_msg =
NULL;
605 ast_debug(2,
"ldap_loadentry dn=%s\n", dn);
608 result = ldap_search_ext_s(
ldapConn, dn, LDAP_SCOPE_BASE,
609 "(objectclass=*)",
NULL, 0,
NULL,
NULL,
NULL, LDAP_NO_LIMIT, &ldap_result_msg);
614 usleep(500000L * tries);
626 if (result != LDAP_SUCCESS) {
627 ast_log(
LOG_WARNING,
"Failed to query directory. Error: %s.\n", ldap_err2string(result));
633 unsigned int *entries_count_ptr =
NULL;
635 if ((num_entry = ldap_count_entries(
ldapConn, ldap_result_msg)) > 0) {
636 ast_debug(3,
"num_entry: %d\n", num_entry);
643 ast_debug(2,
"Could not find any entry dn=%s.\n", dn);
646 ldap_msgfree(ldap_result_msg);
670 #define MAXRESULT 2048 671 char *ret_string =
NULL;
677 ast_debug(2,
"substituted: string: '%s' => '%s' \n",
string, ret_string);
685 char *cbasedn =
NULL;
689 if (*cbasedn ==
'"') {
692 int len = strlen(cbasedn);
693 if (cbasedn[len - 1] ==
'"')
694 cbasedn[len - 1] =
'\0';
705 ast_debug(2,
"basedn: '%s' => '%s' \n", basedn, cbasedn);
714 int search_len = strlen(search);
715 int by_len = strlen(by);
717 char *p = strstr(
string, search);
722 if (by_len == search_len) {
723 memcpy(p, by, by_len);
725 memmove(p + by_len, p + search_len, strlen(p + search_len) + 1);
726 memcpy(p, by, by_len);
728 p = strstr(p + by_len, search);
740 char *new_name =
NULL;
741 char *new_value =
NULL;
742 char *like_pos = strstr(name,
" LIKE");
744 ast_debug(2,
"name='%s' value='%s'\n", name, value);
750 new_name[
len] =
'\0';
788 if (config != base_table_config
794 for (field = fields; field; field = field->
next) {
811 const char *basedn,
const char *table_name,
const struct ast_variable *fields)
820 LDAPMessage *ldap_result_msg =
NULL;
830 " and 1 value to search on.\n");
861 result = ldap_search_ext_s(
ldapConn, clean_basedn,
865 ast_debug(1,
"Failed to query directory. Try %d/10\n", tries + 1);
879 if (result != LDAP_SUCCESS) {
880 ast_log(
LOG_WARNING,
"Failed to query directory. Error: %s.\n", ldap_err2string(result));
885 if (ldap_count_entries(
ldapConn, ldap_result_msg) > 0) {
892 ldap_msgfree(ldap_result_msg);
902 if (strcasecmp(tmp->
name,
"accountBaseDN") == 0) {
909 int base_var_found = 0;
913 if (strcasecmp(test_var->
name, base_var->
name) == 0) {
917 test_var = test_var->
next;
920 if (base_var_found) {
931 base_var->
next = append_var;
935 append_var = base_var;
940 if (!tmp->
next && append_var) {
941 tmp->
next = append_var;
963 const char *newparam, *newval;
965 while ((newparam = va_arg(ap,
const char *))) {
968 newval = va_arg(ap,
const char *);
974 field->
next = fields;
984 const char *basedn,
const char *table_name, ...)
990 va_start(ap, table_name);
1004 const char *table_name,
const struct ast_variable *fields)
1016 while (last_var->
next) {
1017 last_var = last_var->
next;
1019 last_var->
next = *p;
1039 const char *table_name,
const struct ast_variable *fields)
1042 const char *initfield =
NULL;
1048 ast_log(
LOG_WARNING,
"realtime retrieval requires at least 1 parameter and 1 value to search on.\n");
1052 if ((op = strchr(initfield,
' '))) {
1071 if (initfield && !strcmp(initfield, var->
name)) {
1127 const char *
file,
struct ast_config *cfg,
struct ast_flags config_flags,
const char *sugg_incl,
const char *who_asked)
1129 unsigned int vars_count = 0;
1134 const char *last_category =
NULL;
1135 int last_category_metric = 0;
1144 vars =
realtime_ldap_base(&vars_count, basedn, table_name,
"filename", file,
"commented",
"FALSE",
NULL);
1155 if (!(categories =
ast_calloc(vars_count,
sizeof(*categories)))) {
1159 for (vars_count = 0, p = vars; *p; p++) {
1169 (dn ? dn->
value :
"?"), file);
1170 }
else if (!cat_metric) {
1171 ast_log(
LOG_ERROR,
"No category metric in entry '%s'(category: %s) for file '%s'.\n",
1172 (dn ? dn->
value :
"?"), category->
value, file);
1173 }
else if (!var_metric) {
1174 ast_log(
LOG_ERROR,
"No variable metric in entry '%s'(category: %s) for file '%s'.\n",
1175 (dn ? dn->
value :
"?"), category->
value, file);
1176 }
else if (!var_name) {
1177 ast_log(
LOG_ERROR,
"No variable name in entry '%s' (category: %s metric: %s) for file '%s'.\n",
1179 cat_metric->
value, file);
1180 }
else if (!var_val) {
1181 ast_log(
LOG_ERROR,
"No variable value in entry '%s' (category: %s metric: %s variable: %s) for file '%s'.\n",
1185 categories[vars_count].
name = category->
value;
1186 categories[vars_count].
metric = atoi(cat_metric->
value);
1202 for (i = 0; i < vars_count; i++) {
1211 if (!last_category || strcmp(last_category, categories[i].
name) ||
1212 last_category_metric != categories[i].
metric) {
1218 last_category = categories[i].
name;
1219 last_category_metric = categories[i].
metric;
1250 mod = ldap_memcalloc(1,
sizeof(LDAPMod));
1251 type = ldap_strdup(attribute);
1253 if (!(mod && type)) {
1254 ast_log(
LOG_ERROR,
"Memory allocation failure creating LDAP modification\n");
1260 mod->mod_type =
type;
1262 if (strlen(new_value)) {
1264 values = ldap_memcalloc(2,
sizeof(
char *));
1265 value = ldap_strdup(new_value);
1267 if (!(values && value)) {
1268 ast_log(
LOG_ERROR,
"Memory allocation failure creating LDAP modification\n");
1269 ldap_memfree(value);
1270 ldap_memfree(values);
1276 mod->mod_op = LDAP_MOD_REPLACE;
1277 mod->mod_values = values;
1278 mod->mod_values[0] =
value;
1280 mod->mod_op = LDAP_MOD_DELETE;
1299 if (src->mod_op != LDAP_MOD_REPLACE) {
1303 new_buffer = ldap_memrealloc(
1305 strlen(src->mod_values[0]) + strlen(new_value) +
sizeof(
";"));
1308 ast_log(
LOG_ERROR,
"Memory allocation failure creating LDAP modification\n");
1312 strcat(new_buffer,
";");
1313 strcat(new_buffer, new_value);
1315 src->mod_values[0] = new_buffer;
1333 mod = ldap_memcalloc(1,
sizeof(LDAPMod));
1334 type = ldap_strdup(src->mod_type);
1336 if (!(mod && type)) {
1337 ast_log(
LOG_ERROR,
"Memory allocation failure creating LDAP modification\n");
1343 if (src->mod_op == LDAP_MOD_REPLACE) {
1346 values = ldap_memcalloc(2,
sizeof(
char *));
1347 value = ldap_strdup(src->mod_values[0]);
1349 if (!(values && value)) {
1350 ast_log(
LOG_ERROR,
"Memory allocation failure creating LDAP modification\n");
1351 ldap_memfree(value);
1352 ldap_memfree(values);
1361 mod->mod_op = src->mod_op;
1362 mod->mod_type =
type;
1363 mod->mod_values = values;
1379 for (i = 0; modifications[i]; i++) {
1380 if (modifications[i]->mod_op == LDAP_MOD_REPLACE &&
1381 !strcasecmp(modifications[i]->mod_type, lookup)) {
1382 return modifications[i];
1399 BerElement *ber =
NULL;
1402 attribute = ldap_first_attribute(
ldapConn, entry, &ber);
1404 if (!strcasecmp(attribute, lookup)) {
1405 ldap_memfree(attribute);
1409 ldap_memfree(attribute);
1410 attribute = ldap_next_attribute(
ldapConn, entry, ber);
1434 size_t k, i, remove_count;
1437 for (i = remove_count = 0; mods[i]; i++) {
1438 if (mods[i]->mod_op == LDAP_MOD_DELETE
1444 if (!remove_count) {
1448 copies = ldap_memcalloc(i - remove_count + 1,
sizeof(LDAPMod *));
1450 ast_log(
LOG_ERROR,
"Memory allocation failure massaging LDAP modification\n");
1454 for (i = k = 0; mods[i]; i++) {
1455 if (mods[i]->mod_op != LDAP_MOD_DELETE
1459 ast_log(
LOG_ERROR,
"Memory allocation failure massaging LDAP modification\n");
1460 ldap_mods_free(copies, 1);
1465 ast_debug(3,
"Skipping %s deletion because it doesn't exist\n",
1485 for (var = vars;
var; var = var->
next) {
1495 char *clean_basedn =
NULL;
1497 int search_result = 0;
1500 size_t update_count, update_index, entry_count;
1502 LDAPMessage *ldap_entry =
NULL;
1503 LDAPMod **modifications;
1504 LDAPMessage *ldap_result_msg =
NULL;
1512 if (!update_count) {
1526 if (!table_config) {
1547 search_result = ldap_search_ext_s(
1559 usleep(500000L * tries);
1571 if (search_result != LDAP_SUCCESS) {
1572 ast_log(
LOG_WARNING,
"Failed to query directory. Error: %s.\n", ldap_err2string(search_result));
1577 entry_count = ldap_count_entries(
ldapConn, ldap_result_msg);
1585 modifications = ldap_memcalloc(update_count + 1,
sizeof(LDAPMod *));
1586 if (!modifications) {
1596 for (field = update_fields, update_index = 0; field; field = field->
next) {
1615 modifications[update_index++] = mod;
1620 ast_debug(3,
"Modifying %zu matched entries\n", entry_count);
1623 for (i = 0; modifications[i]; i++) {
1624 if (modifications[i]->mod_op != LDAP_MOD_DELETE) {
1626 modifications[i]->mod_values[0]);
1633 for (ldap_entry = ldap_first_entry(
ldapConn, ldap_result_msg);
1635 ldap_entry = ldap_next_entry(
ldapConn, ldap_entry)) {
1637 LDAPMod **massaged, **working;
1639 char *dn = ldap_get_dn(
ldapConn, ldap_entry);
1645 working = modifications;
1651 ast_debug(3,
"Nothing left to modify - skipping\n");
1652 ldap_mods_free(massaged, 1);
1659 if ((error = ldap_modify_ext_s(
ldapConn, dn, working,
NULL,
NULL)) != LDAP_SUCCESS) {
1660 ast_log(
LOG_ERROR,
"Couldn't modify dn:%s because %s", dn, ldap_err2string(error));
1664 ldap_mods_free(massaged, 1);
1673 ldap_mods_free(modifications, 1);
1676 ldap_msgfree(ldap_result_msg);
1684 static int update_ldap(
const char *basedn,
const char *table_name,
const char *attribute,
const char *lookup,
const struct ast_variable *fields)
1688 res =
update2_ldap(basedn, table_name, lookup_fields, fields);
1725 ast_log(
LOG_WARNING,
"Couldn't establish connection to LDAP directory. Check debug.\n");
1729 ast_verb(1,
"LDAP RealTime driver loaded.\n");
1753 ast_verb(1,
"LDAP RealTime driver unloaded.\n");
1780 ast_log(
LOG_WARNING,
"Couldn't establish connection to your directory server. Check debug.\n");
1783 ast_verb(2,
"LDAP RealTime driver reloaded.\n");
1794 static const char *
const config[] = {
1795 "basedn",
"host",
"pass",
"port",
"protocol",
"url",
"user",
"version",
NULL 1798 for (i = 0; config[i]; i++) {
1799 if (!strcasecmp(key, config[i])) {
1812 const char *s, *
host;
1814 char *category_name =
NULL;
1830 ast_log(
LOG_NOTICE,
"No directory user found, anonymous binding as default.\n");
1849 if (!(s =
ast_variable_retrieve(config,
"_general",
"port")) || sscanf(s,
"%5d", &port) != 1 || port > 65535) {
1854 snprintf(
url,
sizeof(
url),
"ldap://%s:%d", host, port);
1869 }
else if (sscanf(s,
"%30d", &
version) != 1 || version < 1 || version > 6) {
1877 int is_general = (strcasecmp(category_name,
"_general") == 0);
1878 int is_config = (strcasecmp(category_name,
"config") == 0);
1884 if (!table_config) {
1888 base_table_config = table_config;
1890 static_table_config = table_config;
1892 for (;
var; var = var->
next) {
1893 if (!strcasecmp(var->
name,
"additionalFilter")) {
1912 int bind_result = 0;
1916 ast_debug(2,
"Everything seems fine.\n");
1921 ast_log(
LOG_ERROR,
"Not enough parameters to connect to ldap directory\n");
1925 if (LDAP_SUCCESS != ldap_initialize(&
ldapConn,
url)) {
1926 ast_log(
LOG_ERROR,
"Failed to init ldap connection to '%s'. Check debug for more info.\n",
url);
1930 if (LDAP_OPT_SUCCESS != ldap_set_option(
ldapConn, LDAP_OPT_PROTOCOL_VERSION, &
version)) {
1936 cred.bv_val = (
char *)
pass;
1937 cred.bv_len = strlen(
pass);
1945 if (bind_result == LDAP_SUCCESS) {
1946 ast_debug(2,
"Successfully connected to directory.\n");
1967 e->
command =
"realtime show ldap status";
1969 "Usage: realtime show ldap status\n" 1970 " Shows connection information for the LDAP RealTime driver\n";
2004 .requires =
"extconfig",
struct ast_variable * next
Main Channel structure associated with a channel.
static ast_mutex_t ldap_lock
#define AST_CLI_DEFINE(fn, txt,...)
Asterisk locking-related definitions:
static struct ast_variable ** realtime_ldap_base_ap(unsigned int *entries_count_ptr, const char *basedn, const char *table_name, const struct ast_variable *fields)
LDAP base function.
Asterisk main include file. File version handling, generic pbx functions.
static void append_var_and_value_to_filter(struct ast_str **filter, struct ldap_table_config *table_config, const char *name, const char *value)
Append a name=value filter string. The filter string can grow.
String manipulation functions.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
static LDAPMod * ldap_mod_find(LDAPMod **modifications, const char *lookup)
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
descriptor for a cli entry.
static LDAPMod * ldap_mod_create(const char *attribute, const char *new_value)
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define CONFIG_STATUS_FILEINVALID
static int semicolon_count_str(const char *somestr)
Count semicolons in string.
#define RES_CONFIG_LDAP_CONF
Structure for variables, used for configurations and for channel variables.
static struct ast_variable * variable_named(struct ast_variable *var, const char *name)
Find variable by name.
int ast_config_engine_deregister(struct ast_config_engine *del)
Deregister config engine.
static struct ast_str * create_lookup_filter(struct ldap_table_config *config, const struct ast_variable *fields)
static char * cleaned_basedn(struct ast_channel *channel, const char *basedn)
int ast_config_engine_register(struct ast_config_engine *newconfig)
Register config engine.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
#define ast_mutex_lock(a)
static int ldap_entry_has_attribute(LDAPMessage *entry, const char *lookup)
#define ast_strdup(str)
A wrapper for strdup()
static char * realtime_ldap_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Realtime Status.
static struct ldap_table_config * table_config_new(const char *table_name)
Create a new table_config.
static struct ast_variable * realtime_ldap(const char *basedn, const char *table_name, const struct ast_variable *fields)
See Asterisk doc.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
static int is_ldap_connect_error(int err)
Check if we have a connection error.
static char base_distinguished_name[512]
const char * variable_value
#define ast_verb(level,...)
static struct ldap_table_config * base_table_config
struct ast_config * ast_config_internal_load(const char *configfile, struct ast_config *cfg, struct ast_flags flags, const char *suggested_incl_file, const char *who_asked)
static struct ldap_table_config * table_config_for_table_name(const char *table_name)
Find a table_config.
Configuration engine structure, used to define realtime drivers.
#define ast_strlen_zero(foo)
#define ast_category_new_anonymous()
Create a nameless category that is not backed by a file.
static int config_can_be_inherited(const char *key)
static int replace_string_in_string(char *string, const char *search, const char *by)
Replace <search> by <by> in string.
Configuration File Parser.
void ast_category_rename(struct ast_category *cat, const char *name)
#define ast_debug(level,...)
Log a DEBUG message.
static int compare_categories(const void *a, const void *b)
Sorting alogrithm for qsort to find the order of the variables a and b.
#define ast_config_load(filename, flags)
Load a config file.
static LDAPMod * ldap_mod_duplicate(const LDAPMod *src)
static void table_configs_free(void)
Free table_config.
static struct ast_config_engine ldap_engine
General Asterisk PBX channel definitions.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
static LDAPMod ** massage_mods_for_entry(LDAPMessage *entry, LDAPMod **mods)
static const char * convert_attribute_name_to_ldap(struct ldap_table_config *table_config, const char *attribute_name)
Convert variable name to ldap attribute name.
void ast_config_destroy(struct ast_config *config)
Destroys a config.
struct ast_variable * delimiters
#define ast_strdupa(s)
duplicate a string in memory from the stack
static time_t connect_time
A set of macros to manage forward-linked lists.
static struct ast_variable * realtime_arguments_to_fields(va_list ap)
#define ast_variable_new(name, value, filename)
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
struct ast_config * ast_config_new(void)
Create a new base configuration structure.
static LDAPMod * ldap_mod_append(LDAPMod *src, const char *new_value)
Core PBX routines and definitions.
static const char * convert_attribute_name_from_ldap(struct ldap_table_config *table_config, const char *attribute_name)
Convert ldap attribute name to variable name.
static struct ast_variable ** realtime_ldap_base(unsigned int *entries_count_ptr, const char *basedn, const char *table_name,...)
same as realtime_ldap_base_ap but take variable arguments count list
#define AST_LIST_HEAD_NOLOCK_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
static struct ast_cli_entry ldap_cli[]
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
struct association categories[]
static struct ast_config * realtime_multi_ldap(const char *basedn, const char *table_name, const struct ast_variable *fields)
See Asterisk doc.
static struct ast_variable ** realtime_ldap_result_to_vars(struct ldap_table_config *table_config, LDAPMessage *ldap_result_msg, unsigned int *entries_count_ptr)
Get variables from ldap entry attributes - Should be locked before using it.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
static struct ast_variable * realtime_ldap_entry_to_var(struct ldap_table_config *table_config, LDAPMessage *ldap_entry)
Get variables from ldap entry attributes.
#define ast_calloc(num, len)
A wrapper for calloc()
static void ldap_table_config_add_attribute(struct ldap_table_config *table_config, const char *attribute_name, const char *attribute_value)
add attribute to table config
#define ast_category_new_dynamic(name)
Create a category that is not backed by a file.
static int semicolon_count_var(struct ast_variable *var)
structure to hold users read from users.conf
Structure used to handle boolean flags.
Support for logging to various files, console and syslog Configuration in file logger.conf.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
static int unload_module(void)
Unload Module.
void ast_cli_print_timestr_fromseconds(int fd, int seconds, const char *prefix)
Print on cli a duration in seconds in format s year(s), s week(s), s day(s), s hour(s), s second(s)
void ast_variable_append(struct ast_category *category, struct ast_variable *variable)
#define CONFIG_STATUS_FILEMISSING
void ast_category_append(struct ast_config *config, struct ast_category *cat)
Appends a category to a config.
const char * variable_name
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
static int parse_config(void)
parse the configuration file
Standard Command Line Interface.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
struct ast_variable * attributes
static size_t variables_count(const struct ast_variable *vars)
#define RES_CONFIG_LDAP_DEFAULT_BASEDN
static int update2_ldap(const char *basedn, const char *table_name, const struct ast_variable *lookup_fields, const struct ast_variable *update_fields)
static struct ast_config * config_ldap(const char *basedn, const char *table_name, const char *file, struct ast_config *cfg, struct ast_flags config_flags, const char *sugg_incl, const char *who_asked)
See Asterisk Realtime Documentation.
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
static struct ast_variable * ldap_loadentry(struct ldap_table_config *table_config, const char *dn)
Get LDAP entry by dn and return attributes as variables.
Options provided by main asterisk program.
int error(const char *format,...)
static int filter(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
static int load_module(void)
Load the module.
#define ASTERISK_GPL_KEY
The text the key() function should return.
#define DEBUG_ATLEAST(level)
Asterisk module definitions.
static char * substituted(struct ast_channel *channel, const char *string)
static int update_ldap(const char *basedn, const char *table_name, const char *attribute, const char *lookup, const struct ast_variable *fields)
#define AST_MUTEX_DEFINE_STATIC(mutex)
Should be locked before using it.
static int ldap_reconnect(void)
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
#define ast_mutex_unlock(a)
static struct ldap_table_config * static_table_config