dovecot-2.2: ldap auth: Added %{ldap_ptr:realAttr} to get the va...

dovecot at dovecot.org dovecot at dovecot.org
Mon Mar 18 21:24:10 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/b6986edec17f
changeset: 16036:b6986edec17f
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Mar 18 21:23:54 2013 +0200
description:
ldap auth: Added %{ldap_ptr:realAttr} to get the value from the realAttr.
For example:

password_attrs = \
  =proxy=y, \
  =host=%{ldap_ptr:activeHost}, \
  primaryHost, secondaryHost

Where activeHost's value is either "primaryHost" or "secondaryHost".

diffstat:

 src/auth/db-ldap.c |  16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diffs (47 lines):

diff -r 0b33047566a9 -r b6986edec17f src/auth/db-ldap.c
--- a/src/auth/db-ldap.c	Mon Mar 18 21:20:54 2013 +0200
+++ b/src/auth/db-ldap.c	Mon Mar 18 21:23:54 2013 +0200
@@ -623,6 +623,7 @@
 {
 	static struct var_expand_func_table var_funcs_table[] = {
 		{ "ldap", db_ldap_field_subquery_find },
+		{ "ldap_ptr", db_ldap_field_subquery_find },
 		{ NULL, NULL }
 	};
 	const struct ldap_field *field;
@@ -1251,6 +1252,7 @@
 {
 	static struct var_expand_func_table var_funcs_table[] = {
 		{ "ldap", db_ldap_field_find },
+		{ "ldap_ptr", db_ldap_field_find },
 		{ NULL, NULL }
 	};
 	struct ldap_field_find_context ctx;
@@ -1515,6 +1517,19 @@
 	return ldap_value->values[0];
 }
 
+static const char *db_ldap_field_ptr_expand(const char *data, void *context)
+{
+	struct db_ldap_result_iterate_context *ctx = context;
+	const char *field_name, *suffix;
+
+	suffix = strchr(t_strcut(data, ':'), '@');
+	field_name = db_ldap_field_expand(data, ctx);
+	if (field_name[0] == '\0')
+		return "";
+	field_name = t_strconcat(field_name, suffix, NULL);
+	return db_ldap_field_expand(field_name, ctx);
+}
+
 static const char *const *
 db_ldap_result_return_value(struct db_ldap_result_iterate_context *ctx,
 			    const struct ldap_field *field,
@@ -1522,6 +1537,7 @@
 {
 	static struct var_expand_func_table var_funcs_table[] = {
 		{ "ldap", db_ldap_field_expand },
+		{ "ldap_ptr", db_ldap_field_ptr_expand },
 		{ NULL, NULL }
 	};
 	const struct var_expand_table *var_table;


More information about the dovecot-cvs mailing list