]> git.sur5r.net Git - openldap/commitdiff
group and attribute conversion to berval DN
authorPierangelo Masarati <ando@openldap.org>
Thu, 27 Dec 2001 12:17:28 +0000 (12:17 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 27 Dec 2001 12:17:28 +0000 (12:17 +0000)
servers/slapd/back-ldap/attribute.c
servers/slapd/back-ldap/group.c

index 46cddb2de7fa1067728cf81d910aa3dfba4ca473..baba6eb945575989ae74766633c652e67e3dd6c4 100644 (file)
@@ -25,7 +25,7 @@ ldap_back_attribute(
        Connection *conn,
        Operation *op,
        Entry   *target,
-       const char      *ndn,
+       struct berval   *ndn,
        AttributeDescription *entry_at,
        struct berval ***vals
 )
@@ -40,7 +40,7 @@ ldap_back_attribute(
        LDAP *ld;
 
        *vals = NULL;
-       if (target != NULL && strcmp(target->e_ndn, ndn) == 0) {
+       if (target != NULL && strcmp(target->e_ndn, ndn->bv_val) == 0) {
                /* we already have a copy of the entry */
                /* attribute and objectclass mapping has already been done */
                if ((attr = attr_find(target->e_attrs, entry_at)) == NULL)
@@ -73,7 +73,7 @@ ldap_back_attribute(
                if (ldap_bind_s(ld, li->binddn, li->bindpw, LDAP_AUTH_SIMPLE) == LDAP_SUCCESS) {
                        gattr[0] = mapped;
                        gattr[1] = NULL;
-                       if (ldap_search_ext_s(ld, ndn, LDAP_SCOPE_BASE, "(objectclass=*)",
+                       if (ldap_search_ext_s(ld, ndn->bv_val, LDAP_SCOPE_BASE, "(objectclass=*)",
                                                                        gattr, 0, NULL, NULL, LDAP_NO_LIMIT,
                                                                        LDAP_NO_LIMIT, &result) == LDAP_SUCCESS)
                        {
index 8d2df9814ea86b88a5945cd5bf2563bc36dd4285..ce38c3ae55440462f655a8d0c0b7ec90824f551e 100644 (file)
  */
 int
 ldap_back_group(
-       Backend *be,
-       Connection *conn,
-       Operation *op,
-       Entry   *target,
-       const char      *gr_ndn,
-       const char      *op_ndn,
-       ObjectClassgroup_oc,
+       Backend         *be,
+       Connection      *conn,
+       Operation       *op,
+       Entry           *target,
+       struct berval   *gr_ndn,
+       struct berval   *op_ndn,
+       ObjectClass     *group_oc,
        AttributeDescription* group_at
 )
 {
        struct ldapinfo *li = (struct ldapinfo *) be->be_private;    
        int rc = 1;
        Attribute   *attr;
-       struct berval bv;
 
        LDAPMessage     *result;
        char *gattr[2];
@@ -53,7 +52,7 @@ ldap_back_group(
                group_oc_name = group_oc->soc_oid;
        }
 
-       if (target != NULL && strcmp(target->e_ndn, gr_ndn) == 0) {
+       if (target != NULL && strcmp(target->e_ndn, gr_ndn->bv_val) == 0) {
                /* we already have a copy of the entry */
                /* attribute and objectclass mapping has already been done */
 
@@ -81,9 +80,7 @@ ldap_back_group(
                         * attribute has not been required
                         */
                        if ((attr = attr_find(target->e_attrs, group_at)) != NULL) {
-                               bv.bv_val = (char *) op_ndn;
-                               bv.bv_len = strlen( op_ndn );         
-                               if( value_find( group_at, attr->a_vals, &bv ) != LDAP_SUCCESS  )
+                               if( value_find( group_at, attr->a_vals, op_ndn ) != LDAP_SUCCESS  )
                                        return(1);
                                return(0);
                        } /* else: repeat the search */
@@ -95,19 +92,19 @@ ldap_back_group(
         */
 #ifdef ENABLE_REWRITE
        switch ( rewrite_session( li->rwinfo, "bindDn",
-                               op_ndn, conn, &mop_ndn ) ) {
+                               op_ndn->bv_val, conn, &mop_ndn ) ) {
        case REWRITE_REGEXEC_OK:
                if ( mop_ndn == NULL ) {
-                       mop_ndn = ( char * )op_ndn;
+                       mop_ndn = ( char * )op_ndn->bv_val;
                }
 #ifdef NEW_LOGGING
                LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
                                "[rw] bindDn (op ndn in group):"
-                               " \"%s\" -> \"%s\"\n", op_ndn, mop_ndn ));
+                               " \"%s\" -> \"%s\"\n", op_ndn->bv_val, mop_ndn ));
 #else /* !NEW_LOGGING */
                Debug( LDAP_DEBUG_ARGS,
                        "rw> bindDn (op ndn in group): \"%s\" -> \"%s\"\n%s",
-                       op_ndn, mop_ndn, "" );
+                       op_ndn->bv_val, mop_ndn, "" );
 #endif /* !NEW_LOGGING */
                break;
        
@@ -121,20 +118,20 @@ ldap_back_group(
         * Rewrite the gr ndn if needed
         */
         switch ( rewrite_session( li->rwinfo, "searchBase",
-                               gr_ndn, conn, &mgr_ndn ) ) {
+                               gr_ndn->bv_val, conn, &mgr_ndn ) ) {
        case REWRITE_REGEXEC_OK:
                if ( mgr_ndn == NULL ) {
-                       mgr_ndn = ( char * )gr_ndn;
+                       mgr_ndn = ( char * )gr_ndn->bv_val;
                }
 #ifdef NEW_LOGGING
                LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
                                "[rw] searchBase (gr ndn in group):"
-                               " \"%s\" -> \"%s\"\n%s", gr_ndn, mgr_ndn ));
+                               " \"%s\" -> \"%s\"\n%s", gr_ndn->bv_val, mgr_ndn ));
 #else /* !NEW_LOGGING */
                Debug( LDAP_DEBUG_ARGS,
                        "rw> searchBase (gr ndn in group):"
                        " \"%s\" -> \"%s\"\n%s",
-                       gr_ndn, mgr_ndn, "" );
+                       gr_ndn->bv_val, mgr_ndn, "" );
 #endif /* !NEW_LOGGING */
                break;
        
@@ -201,12 +198,12 @@ cleanup:;
        }
        ch_free(filter);
 #ifdef ENABLE_REWRITE
-       if ( mop_ndn != op_ndn ) {
+       if ( mop_ndn != op_ndn->bv_val ) {
 #endif /* ENABLE_REWRITE */
                free( mop_ndn );
 #ifdef ENABLE_REWRITE
        }
-       if ( mgr_ndn != gr_ndn ) {
+       if ( mgr_ndn != gr_ndn->bv_val ) {
 #endif /* ENABLE_REWRITE */
                free( mgr_ndn );
 #ifdef ENABLE_REWRITE