Ignore:
Timestamp:
May 27, 2009, 12:08:58 PM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.2 branch to 3.2.11

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.2.x/source/passdb/pdb_tdb.c

    r234 r235  
    14071407                           int flag)
    14081408{
    1409         if (!pdb_get_user_rid(newpwd)) {
     1409        uint32_t oldrid;
     1410        uint32_t newrid;
     1411
     1412        if (!(newrid = pdb_get_user_rid(newpwd))) {
    14101413                DEBUG(0,("tdb_update_sam: struct samu (%s) with no RID!\n",
    14111414                         pdb_get_username(newpwd)));
     
    14131416        }
    14141417
     1418        oldrid = newrid;
     1419
    14151420        /* open the database */
    14161421
     
    14251430        }
    14261431
    1427         if (!tdb_update_samacct_only(newpwd, flag)
    1428             || !tdb_update_ridrec_only(newpwd, flag)) {
     1432        /* If we are updating, we may be changing this users RID. Retrieve the old RID
     1433           so we can check. */
     1434
     1435        if (flag == TDB_MODIFY) {
     1436                struct samu *account = samu_new(talloc_tos());
     1437                if (account == NULL) {
     1438                        DEBUG(0,("tdb_update_sam: samu_new() failed\n"));
     1439                        goto cancel;
     1440                }
     1441                if (!NT_STATUS_IS_OK(tdbsam_getsampwnam(my_methods, account, pdb_get_username(newpwd)))) {
     1442                        DEBUG(0,("tdb_update_sam: tdbsam_getsampwnam() for %s failed\n",
     1443                                pdb_get_username(newpwd)));
     1444                        TALLOC_FREE(account);
     1445                        goto cancel;
     1446                }
     1447                if (!(oldrid = pdb_get_user_rid(account))) {
     1448                        DEBUG(0,("tdb_update_sam: pdb_get_user_rid() failed\n"));
     1449                        TALLOC_FREE(account);
     1450                        goto cancel;
     1451                }
     1452                TALLOC_FREE(account);
     1453        }
     1454
     1455        /* Update the new samu entry. */
     1456        if (!tdb_update_samacct_only(newpwd, flag)) {
    14291457                goto cancel;
     1458        }
     1459
     1460        /* Now take care of the case where the RID changed. We need
     1461         * to delete the old RID key and add the new. */
     1462
     1463        if (flag == TDB_MODIFY && newrid != oldrid) {
     1464                fstring keystr;
     1465
     1466                /* Delete old RID key */
     1467                DEBUG(10, ("tdb_update_sam: Deleting key for RID %u\n", oldrid));
     1468                slprintf(keystr, sizeof(keystr) - 1, "%s%.8x", RIDPREFIX, oldrid);
     1469                if (!NT_STATUS_IS_OK(dbwrap_delete_bystring(db_sam, keystr))) {
     1470                        DEBUG(0, ("tdb_update_sam: Can't delete %s\n", keystr));
     1471                        goto cancel;
     1472                }
     1473                /* Insert new RID key */
     1474                DEBUG(10, ("tdb_update_sam: Inserting key for RID %u\n", newrid));
     1475                if (!tdb_update_ridrec_only(newpwd, TDB_INSERT)) {
     1476                        goto cancel;
     1477                }
     1478        } else {
     1479                DEBUG(10, ("tdb_update_sam: %s key for RID %u\n",
     1480                        flag == TDB_MODIFY ? "Updating" : "Inserting", newrid));
     1481                if (!tdb_update_ridrec_only(newpwd, flag)) {
     1482                        goto cancel;
     1483                }
    14301484        }
    14311485
Note: See TracChangeset for help on using the changeset viewer.