Ignore:
Timestamp:
May 26, 2009, 9:44:50 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.2 branch to 3.2.6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.2.x/source/libads/ldap.c

    r138 r228  
    302302                                c_realm = lp_workgroup();
    303303                }
    304 
    305                 if ( !c_realm || !*c_realm ) {
    306                         DEBUG(0,("ads_find_dc: no realm or workgroup!  Don't know what to do\n"));
    307                         return NT_STATUS_INVALID_PARAMETER; /* rather need MISSING_PARAMETER ... */
    308                 }
     304        }
     305
     306        if ( !c_realm || !*c_realm ) {
     307                DEBUG(0,("ads_find_dc: no realm or workgroup!  Don't know what to do\n"));
     308                return NT_STATUS_INVALID_PARAMETER; /* rather need MISSING_PARAMETER ... */
    309309        }
    310310
     
    26402640                        ads->server.ldap_server )) == NULL )
    26412641                {
     2642                        status = ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
    26422643                        goto done;
    26432644                }
     
    29222923/**
    29232924 * pull a DOM_SID from an extended dn string
    2924  * @param mem_ctx TALLOC_CTX 
     2925 * @param mem_ctx TALLOC_CTX
    29252926 * @param extended_dn string
    29262927 * @param flags string type of extended_dn
    29272928 * @param sid pointer to a DOM_SID
    2928  * @return boolean inidicating success
    2929  **/
    2930 bool ads_get_sid_from_extended_dn(TALLOC_CTX *mem_ctx,
    2931                                   const char *extended_dn,
    2932                                   enum ads_extended_dn_flags flags,
    2933                                   DOM_SID *sid)
     2929 * @return NT_STATUS_OK on success,
     2930 *         NT_INVALID_PARAMETER on error,
     2931 *         NT_STATUS_NOT_FOUND if no SID present
     2932 **/
     2933ADS_STATUS ads_get_sid_from_extended_dn(TALLOC_CTX *mem_ctx,
     2934                                        const char *extended_dn,
     2935                                        enum ads_extended_dn_flags flags,
     2936                                        DOM_SID *sid)
    29342937{
    29352938        char *p, *q, *dn;
    29362939
    29372940        if (!extended_dn) {
    2938                 return False;
     2941                return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER);
    29392942        }
    29402943
    29412944        /* otherwise extended_dn gets stripped off */
    29422945        if ((dn = talloc_strdup(mem_ctx, extended_dn)) == NULL) {
    2943                 return False;
    2944         }
    2945         /* 
     2946                return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER);
     2947        }
     2948        /*
    29462949         * ADS_EXTENDED_DN_HEX_STRING:
    29472950         * <GUID=238e1963cb390f4bb032ba0105525a29>;<SID=010500000000000515000000bb68c8fd6b61b427572eb04556040000>;CN=gd,OU=berlin,OU=suse,DC=ber,DC=suse,DC=de
    29482951         *
    29492952         * ADS_EXTENDED_DN_STRING (only with w2k3):
    2950         <GUID=63198e23-39cb-4b0f-b032-ba0105525a29>;<SID=S-1-5-21-4257769659-666132843-1169174103-1110>;CN=gd,OU=berlin,OU=suse,DC=ber,DC=suse,DC=de
     2953         * <GUID=63198e23-39cb-4b0f-b032-ba0105525a29>;<SID=S-1-5-21-4257769659-666132843-1169174103-1110>;CN=gd,OU=berlin,OU=suse,DC=ber,DC=suse,DC=de
     2954         *
     2955         * Object with no SID, such as an Exchange Public Folder
     2956         * <GUID=28907fb4bdf6854993e7f0a10b504e7c>;CN=public,CN=Microsoft Exchange System Objects,DC=sd2k3ms,DC=west,DC=isilon,DC=com
    29512957         */
    29522958
    29532959        p = strchr(dn, ';');
    29542960        if (!p) {
    2955                 return False;
     2961                return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER);
    29562962        }
    29572963
    29582964        if (strncmp(p, ";<SID=", strlen(";<SID=")) != 0) {
    2959                 return False;
     2965                DEBUG(5,("No SID present in extended dn\n"));
     2966                return ADS_ERROR_NT(NT_STATUS_NOT_FOUND);
    29602967        }
    29612968
     
    29642971        q = strchr(p, '>');
    29652972        if (!q) {
    2966                 return False;
    2967         }
    2968        
     2973                return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER);
     2974        }
     2975
    29692976        *q = '\0';
    29702977
     
    29722979
    29732980        switch (flags) {
    2974        
     2981
    29752982        case ADS_EXTENDED_DN_STRING:
    29762983                if (!string_to_sid(sid, p)) {
    2977                         return False;
     2984                        return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER);
    29782985                }
    29792986                break;
     
    29842991                buf_len = strhex_to_str(buf, sizeof(buf), p, strlen(p));
    29852992                if (buf_len == 0) {
    2986                         return False;
     2993                        return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER);
    29872994                }
    29882995
    29892996                if (!sid_parse(buf, buf_len, sid)) {
    29902997                        DEBUG(10,("failed to parse sid\n"));
    2991                         return False;
     2998                        return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER);
    29922999                }
    29933000                break;
     
    29953002        default:
    29963003                DEBUG(10,("unknown extended dn format\n"));
    2997                 return False;
    2998         }
    2999 
    3000         return True;
     3004                return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER);
     3005        }
     3006
     3007        return ADS_ERROR_NT(NT_STATUS_OK);
    30013008}
    30023009
     
    30113018 * @return the count of SIDs pulled
    30123019 **/
    3013  int ads_pull_sids_from_extendeddn(ADS_STRUCT *ads, 
    3014                                    TALLOC_CTX *mem_ctx, 
    3015                                    LDAPMessage *msg, 
     3020 int ads_pull_sids_from_extendeddn(ADS_STRUCT *ads,
     3021                                   TALLOC_CTX *mem_ctx,
     3022                                   LDAPMessage *msg,
    30163023                                   const char *field,
    30173024                                   enum ads_extended_dn_flags flags,
     
    30193026{
    30203027        int i;
    3021         size_t dn_count;
     3028        ADS_STATUS rc;
     3029        size_t dn_count, ret_count = 0;
    30223030        char **dn_strings;
    30233031
    3024         if ((dn_strings = ads_pull_strings(ads, mem_ctx, msg, field, 
     3032        if ((dn_strings = ads_pull_strings(ads, mem_ctx, msg, field,
    30253033                                           &dn_count)) == NULL) {
    30263034                return 0;
     
    30343042
    30353043        for (i=0; i<dn_count; i++) {
    3036 
    3037                 if (!ads_get_sid_from_extended_dn(mem_ctx, dn_strings[i],
    3038                                                   flags, &(*sids)[i])) {
    3039                         TALLOC_FREE(*sids);
    3040                         TALLOC_FREE(dn_strings);
    3041                         return 0;
    3042                 }
     3044                rc = ads_get_sid_from_extended_dn(mem_ctx, dn_strings[i],
     3045                                                  flags, &(*sids)[i]);
     3046                if (!ADS_ERR_OK(rc)) {
     3047                        if (NT_STATUS_EQUAL(ads_ntstatus(rc),
     3048                            NT_STATUS_NOT_FOUND)) {
     3049                                continue;
     3050                        }
     3051                        else {
     3052                                TALLOC_FREE(*sids);
     3053                                TALLOC_FREE(dn_strings);
     3054                                return 0;
     3055                        }
     3056                }
     3057                ret_count++;
    30433058        }
    30443059
    30453060        TALLOC_FREE(dn_strings);
    30463061
    3047         return dn_count;
     3062        return ret_count;
    30483063}
    30493064
Note: See TracChangeset for help on using the changeset viewer.