Changeset 228 for branches/samba-3.2.x/source/libads/ldap.c
- Timestamp:
- May 26, 2009, 9:44:50 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.2.x/source/libads/ldap.c
r138 r228 302 302 c_realm = lp_workgroup(); 303 303 } 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 ... */ 309 309 } 310 310 … … 2640 2640 ads->server.ldap_server )) == NULL ) 2641 2641 { 2642 status = ADS_ERROR_NT(NT_STATUS_NO_MEMORY); 2642 2643 goto done; 2643 2644 } … … 2922 2923 /** 2923 2924 * pull a DOM_SID from an extended dn string 2924 * @param mem_ctx TALLOC_CTX 2925 * @param mem_ctx TALLOC_CTX 2925 2926 * @param extended_dn string 2926 2927 * @param flags string type of extended_dn 2927 2928 * @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 **/ 2933 ADS_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) 2934 2937 { 2935 2938 char *p, *q, *dn; 2936 2939 2937 2940 if (!extended_dn) { 2938 return False;2941 return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER); 2939 2942 } 2940 2943 2941 2944 /* otherwise extended_dn gets stripped off */ 2942 2945 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 /* 2946 2949 * ADS_EXTENDED_DN_HEX_STRING: 2947 2950 * <GUID=238e1963cb390f4bb032ba0105525a29>;<SID=010500000000000515000000bb68c8fd6b61b427572eb04556040000>;CN=gd,OU=berlin,OU=suse,DC=ber,DC=suse,DC=de 2948 2951 * 2949 2952 * 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 2951 2957 */ 2952 2958 2953 2959 p = strchr(dn, ';'); 2954 2960 if (!p) { 2955 return False;2961 return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER); 2956 2962 } 2957 2963 2958 2964 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); 2960 2967 } 2961 2968 … … 2964 2971 q = strchr(p, '>'); 2965 2972 if (!q) { 2966 return False;2967 } 2968 2973 return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER); 2974 } 2975 2969 2976 *q = '\0'; 2970 2977 … … 2972 2979 2973 2980 switch (flags) { 2974 2981 2975 2982 case ADS_EXTENDED_DN_STRING: 2976 2983 if (!string_to_sid(sid, p)) { 2977 return False;2984 return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER); 2978 2985 } 2979 2986 break; … … 2984 2991 buf_len = strhex_to_str(buf, sizeof(buf), p, strlen(p)); 2985 2992 if (buf_len == 0) { 2986 return False;2993 return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER); 2987 2994 } 2988 2995 2989 2996 if (!sid_parse(buf, buf_len, sid)) { 2990 2997 DEBUG(10,("failed to parse sid\n")); 2991 return False;2998 return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER); 2992 2999 } 2993 3000 break; … … 2995 3002 default: 2996 3003 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); 3001 3008 } 3002 3009 … … 3011 3018 * @return the count of SIDs pulled 3012 3019 **/ 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, 3016 3023 const char *field, 3017 3024 enum ads_extended_dn_flags flags, … … 3019 3026 { 3020 3027 int i; 3021 size_t dn_count; 3028 ADS_STATUS rc; 3029 size_t dn_count, ret_count = 0; 3022 3030 char **dn_strings; 3023 3031 3024 if ((dn_strings = ads_pull_strings(ads, mem_ctx, msg, field, 3032 if ((dn_strings = ads_pull_strings(ads, mem_ctx, msg, field, 3025 3033 &dn_count)) == NULL) { 3026 3034 return 0; … … 3034 3042 3035 3043 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++; 3043 3058 } 3044 3059 3045 3060 TALLOC_FREE(dn_strings); 3046 3061 3047 return dn_count;3062 return ret_count; 3048 3063 } 3049 3064
Note:
See TracChangeset
for help on using the changeset viewer.