+
+#ifdef ENABLE_REWRITE
+int
+ldap_dnattr_rewrite(
+ struct rewrite_info *rwinfo,
+ BerVarray a_vals,
+ void *cookie
+)
+{
+ char *mattr;
+
+ for ( ; a_vals->bv_val != NULL; a_vals++ ) {
+ switch ( rewrite_session( rwinfo, "bindDn", a_vals->bv_val,
+ cookie, &mattr )) {
+ case REWRITE_REGEXEC_OK:
+ if ( mattr == NULL ) {
+ /* no substitution */
+ continue;
+ }
+#ifdef NEW_LOGGING
+ LDAP_LOG( BACK_LDAP, DETAIL1,
+ "[rw] bindDn (in add of dn-valued"
+ " attr): \"%s\" -> \"%s\"\n", a_vals->bv_val, mattr, 0 );
+#else /* !NEW_LOGGING */
+ Debug( LDAP_DEBUG_ARGS,
+ "rw> bindDn (in add of dn-valued attr):"
+ " \"%s\" -> \"%s\"\n%s",
+ a_vals->bv_val, mattr, "" );
+#endif /* !NEW_LOGGING */
+
+ /*
+ * FIXME: replacing server-allocated memory
+ * (ch_malloc) with librewrite allocated memory
+ * (malloc)
+ */
+ ch_free( a_vals->bv_val );
+ a_vals->bv_val = mattr;
+ a_vals->bv_len = strlen( mattr );
+
+ break;
+
+ case REWRITE_REGEXEC_UNWILLING:
+
+ case REWRITE_REGEXEC_ERR:
+ /*
+ * FIXME: better give up,
+ * skip the attribute
+ * or leave it untouched?
+ */
+ break;
+ }
+ }
+
+ return 0;
+}
+#endif /* ENABLE_REWRITE */
+