]> git.sur5r.net Git - openldap/commitdiff
append trailing slash to AD canonical if DN is exactly a domain (ITS#3000)
authorPierangelo Masarati <ando@openldap.org>
Fri, 5 Mar 2004 10:36:17 +0000 (10:36 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 5 Mar 2004 10:36:17 +0000 (10:36 +0000)
CHANGES
libraries/libldap/getdn.c

diff --git a/CHANGES b/CHANGES
index ea7e1329b7429e208e27405c13cb21c8cba81a10..2f08963a684a21d31ee410745dca99ea62b16275 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,7 @@ OpenLDAP 2.2 Change Log
 OpenLDAP 2.2.7 Engineering
        Added total operation count in back-monitor (ITS#2983)
        Fixed search abandon handling in backglue (ITS#2999)
+       Fixed (undocumented) AD canonical DN (ITS#3000)
 
 OpenLDAP 2.2.6 Release
        Fixed slapd SASL callback handling (ITS#2926)
index 078d7b0a7c0d794178cd892f58662296632a0d22..0dee28d71f9134f3962030ac9e8413ee99dc2b39 100644 (file)
@@ -3227,6 +3227,8 @@ int ldap_dn2bv_x( LDAPDN dn, struct berval *bv, unsigned flags, void *ctx )
                break;
 
        case LDAP_DN_FORMAT_AD_CANONICAL: {
+               int     trailing_slash = 1;
+
                /*
                 * Sort of UFN for DCE DNs: a slash ('/') separated
                 * global->local DN with no types; strictly speaking,
@@ -3251,7 +3253,7 @@ int ldap_dn2bv_x( LDAPDN dn, struct berval *bv, unsigned flags, void *ctx )
                        len += rdnl;
                }
 
-               if ( ( bv->bv_val = LDAP_MALLOCX( len + 1, ctx ) ) == NULL ) {
+               if ( ( bv->bv_val = LDAP_MALLOCX( len + 2, ctx ) ) == NULL ) {
                        rc = LDAP_NO_MEMORY;
                        break;
                }
@@ -3260,6 +3262,8 @@ int ldap_dn2bv_x( LDAPDN dn, struct berval *bv, unsigned flags, void *ctx )
                if ( iRDN && dn2domain( dn, bv, 0, &iRDN ) != 0 ) {
                        for ( l = bv->bv_len; iRDN >= 0 ; iRDN-- ) {
                                ber_len_t       rdnl;
+
+                               trailing_slash = 0;
                        
                                if ( rdn2ADstr( dn[ iRDN ], &bv->bv_val[ l ], 
                                                flags, &rdnl, 0 ) ) {
@@ -3301,9 +3305,15 @@ int ldap_dn2bv_x( LDAPDN dn, struct berval *bv, unsigned flags, void *ctx )
                        }
                }
 
+               if ( trailing_slash ) {
+                       bv->bv_val[ len ] = '/';
+                       len++;
+               }
+
                bv->bv_len = len;
                bv->bv_val[ bv->bv_len ] = '\0';
 
+
                rc = LDAP_SUCCESS;
        } break;