Changeset 204 for branches/samba-3.2.x/source/winbindd/idmap_ad.c
- Timestamp:
- May 20, 2009, 6:46:53 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.2.x/source/winbindd/idmap_ad.c
r133 r204 749 749 { 750 750 ADS_STRUCT *ads_internal = NULL; 751 const char *attrs[] = {NULL, /* attr_homedir */ 752 NULL, /* attr_shell */ 753 NULL, /* attr_gecos */ 754 NULL, /* attr_gidnumber */ 755 NULL }; 756 char *filter = NULL; 757 LDAPMessage *msg_internal = NULL; 758 ADS_STATUS ads_status = ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL); 759 NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; 760 char *sidstr = NULL; 751 761 752 762 /* Only do query if we are online */ … … 760 770 ads_internal = ad_idmap_cached_connection(); 761 771 762 if ( !ads_internal || !ad_schema ) 772 if ( !ads_internal || !ad_schema ) { 763 773 return NT_STATUS_OBJECT_NAME_NOT_FOUND; 764 765 if ( !homedir || !shell || !gecos ) 774 } 775 776 if (!sid || !homedir || !shell || !gecos) { 766 777 return NT_STATUS_INVALID_PARAMETER; 767 768 *homedir = ads_pull_string( ads, ctx, msg, ad_schema->posix_homedir_attr ); 769 *shell = ads_pull_string( ads, ctx, msg, ad_schema->posix_shell_attr ); 770 *gecos = ads_pull_string( ads, ctx, msg, ad_schema->posix_gecos_attr ); 771 772 if ( gid ) { 773 if ( !ads_pull_uint32(ads, msg, ad_schema->posix_gidnumber_attr, gid ) ) 774 *gid = (uint32)-1; 775 } 776 777 return NT_STATUS_OK; 778 } 779 780 /* See if we can use the ADS connection struct swe were given */ 781 782 if (ads) { 783 *homedir = ads_pull_string( ads, ctx, msg, ad_schema->posix_homedir_attr ); 784 *shell = ads_pull_string( ads, ctx, msg, ad_schema->posix_shell_attr ); 785 *gecos = ads_pull_string( ads, ctx, msg, ad_schema->posix_gecos_attr ); 786 787 if (gid) { 788 if ( !ads_pull_uint32(ads, msg, ad_schema->posix_gidnumber_attr, gid ) ) 789 *gid = (uint32)-1; 790 } 791 792 nt_status = NT_STATUS_OK; 793 goto done; 794 } 795 796 /* Have to do our own query */ 797 798 attrs[0] = ad_schema->posix_homedir_attr; 799 attrs[1] = ad_schema->posix_shell_attr; 800 attrs[2] = ad_schema->posix_gecos_attr; 801 attrs[3] = ad_schema->posix_gidnumber_attr; 802 803 sidstr = sid_binstring(sid); 804 filter = talloc_asprintf(ctx, "(objectSid=%s)", sidstr); 805 SAFE_FREE(sidstr); 806 807 if (!filter) { 808 nt_status = NT_STATUS_NO_MEMORY; 809 goto done; 810 } 811 812 ads_status = ads_search_retry(ads_internal, &msg_internal, filter, attrs); 813 if (!ADS_ERR_OK(ads_status)) { 814 nt_status = ads_ntstatus(ads_status); 815 goto done; 816 } 817 818 *homedir = ads_pull_string(ads_internal, ctx, msg_internal, ad_schema->posix_homedir_attr); 819 *shell = ads_pull_string(ads_internal, ctx, msg_internal, ad_schema->posix_shell_attr); 820 *gecos = ads_pull_string(ads_internal, ctx, msg_internal, ad_schema->posix_gecos_attr); 821 822 if (gid) { 823 if (!ads_pull_uint32(ads_internal, msg_internal, ad_schema->posix_gidnumber_attr, gid)) 824 *gid = (uint32)-1; 825 } 826 827 nt_status = NT_STATUS_OK; 828 829 done: 830 if (msg_internal) { 831 ads_msgfree(ads_internal, msg_internal); 832 } 833 834 return nt_status; 778 835 } 779 836
Note:
See TracChangeset
for help on using the changeset viewer.