Changeset 224 for branches/samba-3.3.x/source/passdb
- Timestamp:
- May 24, 2009, 7:55:48 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.3.x/source/passdb/pdb_tdb.c
r223 r224 818 818 int flag) 819 819 { 820 if (!pdb_get_user_rid(newpwd)) { 820 uint32_t oldrid; 821 uint32_t newrid; 822 823 if (!(newrid = pdb_get_user_rid(newpwd))) { 821 824 DEBUG(0,("tdb_update_sam: struct samu (%s) with no RID!\n", 822 825 pdb_get_username(newpwd))); … … 824 827 } 825 828 829 oldrid = newrid; 830 826 831 /* open the database */ 827 832 … … 836 841 } 837 842 838 if (!tdb_update_samacct_only(newpwd, flag) 839 || !tdb_update_ridrec_only(newpwd, flag)) { 840 goto cancel; 843 /* If we are updating, we may be changing this users RID. Retrieve the old RID 844 so we can check. */ 845 846 if (flag == TDB_MODIFY) { 847 struct samu *account = samu_new(talloc_tos()); 848 if (account == NULL) { 849 DEBUG(0,("tdb_update_sam: samu_new() failed\n")); 850 goto cancel; 851 } 852 if (!NT_STATUS_IS_OK(tdbsam_getsampwnam(my_methods, account, pdb_get_username(newpwd)))) { 853 DEBUG(0,("tdb_update_sam: tdbsam_getsampwnam() for %s failed\n", 854 pdb_get_username(newpwd))); 855 TALLOC_FREE(account); 856 goto cancel; 857 } 858 if (!(oldrid = pdb_get_user_rid(account))) { 859 DEBUG(0,("tdb_update_sam: pdb_get_user_rid() failed\n")); 860 TALLOC_FREE(account); 861 goto cancel; 862 } 863 TALLOC_FREE(account); 864 } 865 866 /* Update the new samu entry. */ 867 if (!tdb_update_samacct_only(newpwd, flag)) { 868 goto cancel; 869 } 870 871 /* Now take care of the case where the RID changed. We need 872 * to delete the old RID key and add the new. */ 873 874 if (flag == TDB_MODIFY && newrid != oldrid) { 875 fstring keystr; 876 877 /* Delete old RID key */ 878 DEBUG(10, ("tdb_update_sam: Deleting key for RID %u\n", oldrid)); 879 slprintf(keystr, sizeof(keystr) - 1, "%s%.8x", RIDPREFIX, oldrid); 880 if (!NT_STATUS_IS_OK(dbwrap_delete_bystring(db_sam, keystr))) { 881 DEBUG(0, ("tdb_update_sam: Can't delete %s\n", keystr)); 882 goto cancel; 883 } 884 /* Insert new RID key */ 885 DEBUG(10, ("tdb_update_sam: Inserting key for RID %u\n", newrid)); 886 if (!tdb_update_ridrec_only(newpwd, TDB_INSERT)) { 887 goto cancel; 888 } 889 } else { 890 DEBUG(10, ("tdb_update_sam: %s key for RID %u\n", 891 flag == TDB_MODIFY ? "Updating" : "Inserting", newrid)); 892 if (!tdb_update_ridrec_only(newpwd, flag)) { 893 goto cancel; 894 } 841 895 } 842 896
Note:
See TracChangeset
for help on using the changeset viewer.