Perhaps one of the most common questions I'm asked is: "Can I move my user from one computer to another?" or "Can I change my username?". The simple answer is to both is yes... but the mechanics providing that answer are, I dare say, more complex.
In Windows NT Architecture there are two concepts that control a user's experience with the operating system. The first one, the account, is responsible for security settings, password management, Access Control Lists (ACLs), Domain Membership, and most other security related tasks. The second, the profile, stores user data (files, cookies, backgrounds, etc) and settings (preferences, e-mail settings, themes, start bar configuration, etc).
While they are interelated, the account and the profile are two DIFFERENT things. That is to say, a user can have only an account on a computer (the profile should automatically be created at first logon), or only a profile on a computer (the files and settings exist, but the user cannot logon to access them). They are connected via an SID (Security Identifier) which is stored in the registry. Should this connection be severed (which can and does happen), restoration can be a long painstaking process to the user who doesn't understand the profile and the account.
The SID
This portion covers a more technical approach to the user account by explaining the SID. While interesting (and something I hope you'll enjoy reading) it is not critical to your understanding of the Account versus the Profile. I explain the relationship between the two (which occurs via SID) in the last paragraph before the section titled "The Account".
When a Windows XP computer is first configured, it remains non-uniquely identifiable until it passes the graphical portion of Windows XP setup. At that point, the domain SID is randomly generated for the computer in the format S-1-5-[32 bit key]-[32 bit key]-[32 bit key]. This SID becomes the integral component of Windows NT security on that machine. It is used to establish trust relationships between Domains and the computer, to propogate security settings across the computer, and to establish simple file sharing in a workgroup environment.
At the time of the original SID generation there is also a series of accounts created, where the last portion of the SID is an RID (Relative Identifier) unique to the user:
S-1-5-18: Local Service
S-1-5-19: NT Authority
S-1-5-
domain-500: Administrator
S-1-5-
domain-501: Guest
This is an abbreviated list. MS Provides a
full list.
It follows then that each time a new
account is created, a new SID is generated for that account. Unlike the generation of the domain SID, this only involves iterating the RID by one, and atatching it to the domain SID. For example, your "personal" user accounts on a computer might be:
S-1-5-
domain-1003: Joe
S-1-5-
domain-1007: Fred Johnson
S-1-5-
domain-1012: Mom
NOTE: The potential gaps between RID's exist because Windows uses the SID for security objects other than users as well.
Any security request or operation made on the machine is done with the SID. The process which allows queries based on SAM Account Names to be made (or queries to be returned via their SAM Account Name) is called SID/Name translation. Basically, internally Windows refers to everything by it's SID. ACL's are created and destroyed by SID's, foreign computer's expect an SID, etc.
For convenience's sake, Windows uses the SAM Account name to refer to user objects externally. This can create a potential security hole if Anonymous SID/Name translation is enabled (it is disabled by default on all XP SP2 systems). If an anonymous user is granted access to your machine at any point (Windows file share, IIS Share, FTP service, etc) an anonymous SID/Name translation attack could be launched. Once the domain SID is obtained, the system's security would be completely compromised.
I mentioned earlier that Windows uses the SID to maintain the relationship between an account and a profile. Remember, the SID
is, quintessentially, the account meaning the link only needs to be between the SID and the Profile. This link is stored in the Registry Value (REG_SZ): HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\[
User SID]\ProfileImagePath. The ProfileList key contains a key by SID for each user account on the machine (excluding certain special accounts).
The Account
In Windows XP there are four ways to view and edit User Accounts. The first approach uses a simplified GUI to present your average user with only commonly used options regarding User Accounts. This screen is accessible by default from the Control Panel (User Accounts button), or by typing "control userpasswords" into a run box. This interface is the easiest way to enable/disable Fast User Switching (the ability to have mulitple users logged on simultaneously) and/or the Welcome Screen (required for Fast User Switching; A simplified logon GUI).
It also provides a simple way to create and delete accounts, but it does so in a very limiting fashion. First off, following with the prinicipal of least control, you must have at least one administrator account (other than "administrator") on the computer. Second, the only options available for groups are "Administrator" (Full System Control), "Power User" (very extended system control), and "Restriced User" (enough control to do most common tasks).
Interface number two is really just a glorified version of the simplified user accounts panel. It is accessible from the "Classic Control Panel", or by typing "control userpasswords2" into a run box. There are two differences between the first two interfaces. First, this second interface displays all enabled accounts (including Guest and Administrator) and second, it does not use wizards.
The third interface is the most popular among sysadmins. Unfortunately, it is only available to user's of XP Professional (sorry XP Home guys, you'll have to wait to here about this tool's command line partner). You can access it from the "Advanced" tab of "control userpasswords2", or by opening a new MMC (type "mmc" in a run box) and adding the "Local Users and Groups" snap-in. This tool gives you full graphical access to Windows accounts, enabled, disabled, and otherwise. It also allows you to create your own security/distribution groups, and allows a more intricate level of control over their membership.
The fourth tool "net user"/"net accounts" is not technically the final way to edit user accounts, but it is the final common way. To use it, open a command prompt (type "cmd" in a run box) and type "net user [
command]". This tool can do everything the MMC Snap-In can do, but is obviously a bit more complicated. Help on it is available via the command "net help user" or "net help accounts".
It's great that there are so many ways to edit accounts in Windows NT, but what exactly do those accounts do? The account is a security principle. It supplies credentials for a user to access system resources (files, programs, open processes, etc). It allows you to setup NTFS permissions on files and folders explicit to that user. A user with only an account would be able to FTP or Windows File Share access your computer.
The Profile
User profiles are automatically created the first time a user account is logged into a computer. At that point, the appropriate registry entries are created to associate the account and the profile. All profiles (by default) are stored in the Documents and Settings folder at the root of the Hard Drive (C:). There are ways to change this (including an undocumented
pseudo-hack of the shellfolders registry key), but unless you're in a domain environment, I wouldn't.
The name of the folder created use done heuristically. Windows will first attempt to use the username (EX: C:\Documents and Settings\John). If that is unavailable it will add .DOMAINNAME (computer name for non-domain computers) (EX: C:\Documents and Settings\John.JOHNSCOMPUTER). Barring that, Windows will add .xxx being a three digit number incremented as many times as necessary (EX: C:\Documents and Settings\John.JOHNSCOMPUTER.001). You don't have to know your profile path though, simply typing "%userprofile%" in the address bar automatically takes you there.
By default, the NTFS security descriptors grant full control to the owner (the user account) and the local administrators group. This means User's cannot access each other's documents if they are stored in My Documents or on the Desktop. MS provides a basic solution to this with "Shared Documents". Shared Documents is really the All Users My Documents folder, which by default has Full Control to Everyone security permissions. As a result any file in the Shared Documents folder is accessible to everyone.
The user registry hive (HKEY_CURRENT_USER when logged in, HKEY_USERS\[
User SID] otherwise) is also stored here in the file "ntuser.dat". This is a hidden system file which you should not edit unless you are absolutely confident you know what you are doing. It contains settings such as where your desktop icons are located, what them you're using, etc.
Many program data files and settings are hidden within he user profile as well. For example, two of the most popular e-mail programs, Outlook and Outlook Express store their e-mails/address books in the profile. Outlook has both of these in one database (Personal Folder File format: .pst) located at %userprofile%\Local Settings\Application Data\Microsoft\Outlook\Outlook.pst. OE seperates them. Every folder has it's own .dbx file in the OE store directory: %userprofile%\Local Settings\Application Data\Identities\
OE Identity String\Microsoft\Outlook Express. The Address Book for OE is stored sperately at: %userprofile%\Application Data\Address Book\
username.wab.
Cookies, Favorites, Temporary Internet Files, Temp files, Installer Data, and a whole mess of other stuff is also hidden within various levels of the user profile. If your lucky, the program whose data you want will reference it's location somewhere... otherwise you could be searching for quite a long time.