Changeset 745 for trunk/server/source3/libads/ldap.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/libads/ldap.c
r583 r745 23 23 24 24 #include "includes.h" 25 #include "lib/ldb/include/ldb.h" 25 #include "ads.h" 26 #include "libads/sitename_cache.h" 27 #include "libads/cldap.h" 28 #include "libads/dns.h" 29 #include "../libds/common/flags.h" 30 #include "smbldap.h" 31 #include "../libcli/security/security.h" 26 32 27 33 #ifdef HAVE_LDAP … … 49 55 ****************************************************************/ 50 56 51 static void gotalarm_sig( void)57 static void gotalarm_sig(int signum) 52 58 { 53 59 gotalarm = 1; … … 64 70 /* Setup timeout */ 65 71 gotalarm = 0; 66 CatchSignal(SIGALRM, SIGNAL_CASTgotalarm_sig);72 CatchSignal(SIGALRM, gotalarm_sig); 67 73 alarm(to); 68 74 /* End setup timeout. */ … … 78 84 79 85 /* Teardown timeout. */ 80 CatchSignal(SIGALRM, SIG NAL_CAST SIG_IGN);86 CatchSignal(SIGALRM, SIG_IGN); 81 87 alarm(0); 82 88 … … 104 110 /* Setup alarm timeout.... Do we need both of these ? JRA. */ 105 111 gotalarm = 0; 106 CatchSignal(SIGALRM, SIGNAL_CASTgotalarm_sig);112 CatchSignal(SIGALRM, gotalarm_sig); 107 113 alarm(lp_ldap_timeout()); 108 114 /* End setup timeout. */ … … 113 119 114 120 /* Teardown timeout. */ 115 CatchSignal(SIGALRM, SIG NAL_CAST SIG_IGN);121 CatchSignal(SIGALRM, SIG_IGN); 116 122 alarm(0); 117 123 … … 265 271 SMB_STRDUP(cldap_reply.client_site); 266 272 } 267 ads->server.workgroup = SMB_STRDUP(cldap_reply.domain );273 ads->server.workgroup = SMB_STRDUP(cldap_reply.domain_name); 268 274 269 275 ads->ldap.port = gc ? LDAP_GC_PORT : LDAP_PORT; … … 277 283 278 284 /* Store our site name. */ 279 sitename_store( cldap_reply.domain , cldap_reply.client_site);285 sitename_store( cldap_reply.domain_name, cldap_reply.client_site); 280 286 sitename_store( cldap_reply.dns_domain, cldap_reply.client_site); 281 287 … … 593 599 594 600 ZERO_STRUCT(ads->ldap); 595 ads->ldap.last_attempt = time (NULL);601 ads->ldap.last_attempt = time_mono(NULL); 596 602 ads->ldap.wrap_type = ADS_SASLWRAP_TYPE_PLAIN; 597 603 … … 1602 1608 if (!org_unit || !*org_unit) { 1603 1609 1604 ret = ads_default_ou_string(ads, WELL_KNOWN_GUID_COMPUTERS);1610 ret = ads_default_ou_string(ads, DS_GUID_COMPUTERS_CONTAINER); 1605 1611 1606 1612 /* samba4 might not yet respond to a wellknownobject-query */ … … 2123 2129 int i; 2124 2130 for (i=0; values[i]; i++) { 2125 2126 UUID_FLAT guid; 2127 struct GUID tmp; 2128 2129 memcpy(guid.info, values[i]->bv_val, sizeof(guid.info)); 2130 smb_uuid_unpack(guid, &tmp); 2131 printf("%s: %s\n", field, GUID_string(talloc_tos(), &tmp)); 2131 NTSTATUS status; 2132 DATA_BLOB in = data_blob_const(values[i]->bv_val, values[i]->bv_len); 2133 struct GUID guid; 2134 2135 status = GUID_from_ndr_blob(&in, &guid); 2136 if (NT_STATUS_IS_OK(status)) { 2137 printf("%s: %s\n", field, GUID_string(talloc_tos(), &guid)); 2138 } else { 2139 printf("%s: INVALID GUID\n", field); 2140 } 2132 2141 } 2133 2142 } … … 2140 2149 int i; 2141 2150 for (i=0; values[i]; i++) { 2142 DOM_SIDsid;2151 struct dom_sid sid; 2143 2152 fstring tmp; 2144 2153 if (!sid_parse(values[i]->bv_val, values[i]->bv_len, &sid)) { 2145 continue;2154 return; 2146 2155 } 2147 2156 printf("%s: %s\n", field, sid_to_fstring(tmp, &sid)); … … 2605 2614 bool ads_pull_guid(ADS_STRUCT *ads, LDAPMessage *msg, struct GUID *guid) 2606 2615 { 2607 char **values; 2608 UUID_FLAT flat_guid; 2609 2610 values = ldap_get_values(ads->ldap.ld, msg, "objectGUID"); 2611 if (!values) 2612 return False; 2613 2614 if (values[0]) { 2615 memcpy(&flat_guid.info, values[0], sizeof(UUID_FLAT)); 2616 smb_uuid_unpack(flat_guid, guid); 2617 ldap_value_free(values); 2618 return True; 2619 } 2620 ldap_value_free(values); 2621 return False; 2622 2623 } 2624 2625 2626 /** 2627 * pull a single DOM_SID from a ADS result 2616 DATA_BLOB blob; 2617 NTSTATUS status; 2618 2619 if (!smbldap_talloc_single_blob(talloc_tos(), ads->ldap.ld, msg, "objectGUID", 2620 &blob)) { 2621 return false; 2622 } 2623 2624 status = GUID_from_ndr_blob(&blob, guid); 2625 talloc_free(blob.data); 2626 return NT_STATUS_IS_OK(status); 2627 } 2628 2629 2630 /** 2631 * pull a single struct dom_sid from a ADS result 2628 2632 * @param ads connection to ads server 2629 2633 * @param msg Results of search … … 2633 2637 */ 2634 2638 bool ads_pull_sid(ADS_STRUCT *ads, LDAPMessage *msg, const char *field, 2635 DOM_SID*sid)2639 struct dom_sid *sid) 2636 2640 { 2637 2641 return smbldap_pull_sid(ads->ldap.ld, msg, field, sid); … … 2639 2643 2640 2644 /** 2641 * pull an array of DOM_SIDs from a ADS result2645 * pull an array of struct dom_sids from a ADS result 2642 2646 * @param ads connection to ads server 2643 2647 * @param mem_ctx TALLOC_CTX for allocating sid array … … 2648 2652 **/ 2649 2653 int ads_pull_sids(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, 2650 LDAPMessage *msg, const char *field, DOM_SID**sids)2654 LDAPMessage *msg, const char *field, struct dom_sid **sids) 2651 2655 { 2652 2656 struct berval **values; … … 2663 2667 2664 2668 if (i) { 2665 (*sids) = TALLOC_ARRAY(mem_ctx, DOM_SID, i);2669 (*sids) = TALLOC_ARRAY(mem_ctx, struct dom_sid, i); 2666 2670 if (!(*sids)) { 2667 2671 ldap_value_free_len(values); … … 2687 2691 2688 2692 /** 2689 * pull a SEC_DESCfrom a ADS result2693 * pull a struct security_descriptor from a ADS result 2690 2694 * @param ads connection to ads server 2691 2695 * @param mem_ctx TALLOC_CTX for allocating sid array 2692 2696 * @param msg Results of search 2693 2697 * @param field Attribute to retrieve 2694 * @param sd Pointer to * SEC_DESCto store result (talloc()ed)2698 * @param sd Pointer to *struct security_descriptor to store result (talloc()ed) 2695 2699 * @return boolean inidicating success 2696 2700 */ 2697 2701 bool ads_pull_sd(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, 2698 LDAPMessage *msg, const char *field, SEC_DESC **sd) 2702 LDAPMessage *msg, const char *field, 2703 struct security_descriptor **sd) 2699 2704 { 2700 2705 struct berval **values; … … 2928 2933 * @return status of search 2929 2934 **/ 2930 ADS_STATUS ads_domain_sid(ADS_STRUCT *ads, DOM_SID*sid)2935 ADS_STATUS ads_domain_sid(ADS_STRUCT *ads, struct dom_sid *sid) 2931 2936 { 2932 2937 const char *attrs[] = {"objectSid", NULL}; … … 3167 3172 3168 3173 /** 3169 * pull a DOM_SIDfrom an extended dn string3174 * pull a struct dom_sid from an extended dn string 3170 3175 * @param mem_ctx TALLOC_CTX 3171 3176 * @param extended_dn string 3172 3177 * @param flags string type of extended_dn 3173 * @param sid pointer to a DOM_SID3178 * @param sid pointer to a struct dom_sid 3174 3179 * @return NT_STATUS_OK on success, 3175 3180 * NT_INVALID_PARAMETER on error, … … 3179 3184 const char *extended_dn, 3180 3185 enum ads_extended_dn_flags flags, 3181 DOM_SID*sid)3186 struct dom_sid *sid) 3182 3187 { 3183 3188 char *p, *q, *dn; … … 3254 3259 3255 3260 /** 3256 * pull an array of DOM_SIDs from a ADS result3261 * pull an array of struct dom_sids from a ADS result 3257 3262 * @param ads connection to ads server 3258 3263 * @param mem_ctx TALLOC_CTX for allocating sid array … … 3268 3273 const char *field, 3269 3274 enum ads_extended_dn_flags flags, 3270 DOM_SID**sids)3275 struct dom_sid **sids) 3271 3276 { 3272 3277 int i; … … 3280 3285 } 3281 3286 3282 (*sids) = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID, dn_count + 1);3287 (*sids) = TALLOC_ZERO_ARRAY(mem_ctx, struct dom_sid, dn_count + 1); 3283 3288 if (!(*sids)) { 3284 3289 TALLOC_FREE(dn_strings); … … 3498 3503 3499 3504 hostnameDN = ads_get_dn(ads, talloc_tos(), (LDAPMessage *)msg); 3505 if (hostnameDN == NULL) { 3506 SAFE_FREE(host); 3507 return ADS_ERROR_SYSTEM(ENOENT); 3508 } 3500 3509 3501 3510 rc = ldap_delete_ext_s(ads->ldap.ld, hostnameDN, pldap_control, NULL); … … 3585 3594 * @param mem_ctx TALLOC_CTX for allocating sid array 3586 3595 * @param dn of LDAP object 3587 * @param user_sid pointer to DOM_SID(objectSid)3588 * @param primary_group_sid pointer to DOM_SID(self composed)3596 * @param user_sid pointer to struct dom_sid (objectSid) 3597 * @param primary_group_sid pointer to struct dom_sid (self composed) 3589 3598 * @param sids pointer to sid array to allocate 3590 3599 * @param num_sids counter of SIDs pulled … … 3594 3603 TALLOC_CTX *mem_ctx, 3595 3604 const char *dn, 3596 DOM_SID*user_sid,3597 DOM_SID*primary_group_sid,3598 DOM_SID**sids,3605 struct dom_sid *user_sid, 3606 struct dom_sid *primary_group_sid, 3607 struct dom_sid **sids, 3599 3608 size_t *num_sids) 3600 3609 { … … 3603 3612 int count = 0; 3604 3613 size_t tmp_num_sids; 3605 DOM_SID*tmp_sids;3606 DOM_SIDtmp_user_sid;3607 DOM_SIDtmp_primary_group_sid;3614 struct dom_sid *tmp_sids; 3615 struct dom_sid tmp_user_sid; 3616 struct dom_sid tmp_primary_group_sid; 3608 3617 uint32 pgid; 3609 3618 const char *attrs[] = { … … 3639 3648 * domsid */ 3640 3649 3641 DOM_SID domsid; 3642 uint32 dummy_rid; 3650 struct dom_sid domsid; 3643 3651 3644 3652 sid_copy(&domsid, &tmp_user_sid); 3645 3653 3646 if (!sid_split_rid(&domsid, &dummy_rid)) {3654 if (!sid_split_rid(&domsid, NULL)) { 3647 3655 ads_msgfree(ads, res); 3648 3656 return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
Note:
See TracChangeset
for help on using the changeset viewer.