Announcement

Collapse
No announcement yet.

Documents & Settings folder has domain name appended to username (?)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Documents & Settings folder has domain name appended to username (?)

    We use a Win2k Server AD domain. One of my co-workers is writing a script or macro for some project. He has found that the script / macro doesn't work correctly for one user because her user folder (inside Documents and Settings) has the domain name appended to it. (Instead of the username MEA, it says MEA.AKCHILD).

    We're pretty certain that the system did this because there was already an MEA folder placed there manually. (Long story.)

    I was thinking that the old MEA folder could be renamed, then the new one (MEA.AKCHILD) could be copied to a different safe place to preserve its contents. The current MEA user could have their profile and folder removed from the system. Finally, having this user log in again would (at least in my theory) recreate the traditional, plain MEA folder name.

    Does this make sense to anyone? Is my theory going to bork something? Let me know if I left out any pertinent info.

    Thanks in advance...

  • #2
    Re: Documents & Settings folder has domain name appended to username (?)

    I think you're on the right track.

    This should work:
    1. Log on as an administrator and copy MEA's current profile to a "safe place" using System Properties\User Profiles for 2k or System Properties\Advanced-> click Settings under User Profiles section for XP.
    2. Delete both the local and domain user profile using the same utility as above (be sure to backup anything you need from the local profile)
    3. Have MEA log on/log off. This should recreate the domain user profile folder (without the domain name appended).
    4. Log on as the administrator and copy the saved profile to the newly created folder.
    Regards,
    Jeremy

    Network Consultant/Engineer
    Baltimore - Washington area and beyond
    www.gma-cpa.com

    Comment


    • #3
      Re: Documents & Settings folder has domain name appended to username (?)

      I say, make modifications to the script.
      It should be able to handle these normal situations, don't disturb a good functioning 'environment' for one script/macro that doesn't fit.

      I am sure making an adjustment to the script doesn' t have to take more than 30 minutes, changing the environment, this time and possibly other times too, wil take a lot more.


      \Rems
      Last edited by Rems; 15th June 2007, 19:48.

      This posting is provided "AS IS" with no warranties, and confers no rights.

      __________________

      ** Remember to give credit where credit's due **
      and leave Reputation Points for meaningful posts

      Comment


      • #4
        Re: Documents & Settings folder has domain name appended to username (?)

        Excellent point, Rems.
        Regards,
        Jeremy

        Network Consultant/Engineer
        Baltimore - Washington area and beyond
        www.gma-cpa.com

        Comment


        • #5
          Re: Documents & Settings folder has domain name appended to username (?)

          User logs in.

          A new folder for their profile is created based on their login name.

          That user's SID (Security ID; unique to that users account) is recorded in the registry, along with the path of where that users profile is stored.

          If the users profile for example, "Rems", is already taken it will create Rems.DOMAIN, where domain is the domain you are connected to.

          If Rems.DOMAIN is already being used, it will create a new profile called Rems.DOMAIN.000 and so on.

          The most common reason for this is that the user was created as a console user prior to joining the Domain. It also happens when the User changes from Domain to Workstation, and this is redone back to Domain. It happens when you remove the same username (User Account) and agree to keep all settings. Then re-add the User Account. Windows has to do something, because it is clear to it that the user SID in the existing profile is not identical to the user SID for the user it just authenticated for logon.

          If you are scripting, use this registry location to find the current paths for all valid user profiles:
          HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
          * Users Helping Users *
          MS-MVP Windows Networking

          Comment


          • #6
            Re: Documents & Settings folder has domain name appended to username (?)

            Originally posted by bcastner View Post
            User logs in.

            A new folder for their profile is created based on their login name.

            That user's SID (Security ID; unique to that users account) is recorded in the registry, along with the path of where that users profile is stored.

            If the users profile for example, "Rems", is already taken it will create Rems.DOMAIN, where domain is the domain you are connected to.

            If Rems.DOMAIN is already being used, it will create a new profile called Rems.DOMAIN.000 and so on.

            The most common reason for this is that the user was created as a console user prior to joining the Domain. It also happens when the User changes from Domain to Workstation, and this is redone back to Domain. It happens when you remove the same username (User Account) and agree to keep all settings. Then re-add the User Account. Windows has to do something, because it is clear to it that the user SID in the existing profile is not identical to the user SID for the user it just authenticated for logon.

            If you are scripting, use this registry location to find the current paths for all valid user profiles:
            HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
            Thanks for the assistance, folks! Although my co-worker successfully made the adjustments to the MEA profile (by using the same steps that JeremyW stated), I'll forward this info along to him so that he can look at having the script do its own leg-work of finding the user profiles.

            Thanks!

            Comment


            • #7
              Re: Documents & Settings folder has domain name appended to username (?)

              Finding the registered User Profile path of all the users that are known to this computer:
              Code:
              ' ProfileImagePath(beta).vbs
              ' http://forums.petri.com/showthread.php?p=72430
              
              strUser = "MEA"          '(delete this line if you want to list all Users with existing profiles on this computer)
              LocalAccount = "False"   '(choose "True" or "False" - or.. delete this line if you want both types of accounts)
              
              
              'To compare:
               LocalProfilesFolder = "c:\Documents And Settings" 'subfolders  with:
               RegKey = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
              
              
              Set objWMI = GetObject("winmgmts://./root\cimv2")
              Set WSHShell = Wscript.CreateObject("Wscript.shell")
              set FSO = CreateObject("Scripting.FileSystemObject")
              
              On Error Resume Next
              set Folder = FSO.GetFolder(LocalProfilesFolder)
               For each ProfileFolder in Folder.SubFolders
                 strProfilefolder = ProfileFolder.Name
                 If len(strUser) Then
                      strUserName = strUser
                 Else strUserName = split(strProfilefolder,".")(0)
                 End If
              
                 If len(LocalAccount) Then strUserName = strUserName &"' AND LocalAccount='"&LocalAccount
                 Set objInstances = objWMI.InstancesOf("Win32_Account where SIDtype=1 AND Name='"& strUserName &"'", 48)
              
                  For Each objInstance in objInstances
                     strVar = objInstance.SID
                     sUserProfilePath = WSHShell.RegRead(RegKey&"\"&strVar&"\ProfileImagePath")
                     sProfileFolder2 = (Right(sUserProfilePath,Len(sUserProfilePath)-InStrRev(sUserProfilePath,"\")))
                      If Lcase(strProfilefolder) = LCase(sProfileFolder2) then
                        UserProfile = WSHShell.ExpandEnvironmentStrings(sUserProfilePath)
               msgBox(""""+UserProfile+""""),0,objInstance.Domain+"\"+LCase(objInstance.Name)
                        Exit For
                      End If
                  Next
              
                sUserProfile = vbNullString
               Next
              
              Set objWMI = Nothing
              Set WSHShell = Nothing
              set FSO = Nothing
              
              Wscript.quit
              (this script can be used for one particular user as well as for all users at once. This example script shows what can be done using vbs. But if you are intrested in determining the path of all the users, then it would be better not to resolve the usernames from the folders, but to query the registrykey for all the SID subkeys, and the matching value of 'ProfileImagePath' for every SID. Then resolve domain\usernames from the SIDs. That will be much better)

              Note that only members of the local Administrators Group can write in the profile folders of other user accounts!
              Normaly a script would be running for the currently Logged-on user only, and make only changes to his/her folder at the time. In that case the script can be a lot more simple than the one above.

              \Rems

              EDIT -
              If it is only for the current logged-on account you can use the environment variable: %UserProfile%
              In VisualBasic you can 'expand' the user- and system environment variables, it only takes two lines to get the correct Path of the user.

              Note, when you manualy migrate a User's path of an existing user on the computer, there is a chance that - in particular this %UserProfile% - can become unreliable on that computer! Therefore after the user migration on the local computer check the evironment variable for that particular user.
              - Logon as the user, Run: cmd /k echo "%UserProfile%" and verify it shows the correct path now (others: %AppData% , %LocalAppData% , %HomePath% , %Temp%).
              Last edited by Rems; 20th June 2007, 09:35.

              This posting is provided "AS IS" with no warranties, and confers no rights.

              __________________

              ** Remember to give credit where credit's due **
              and leave Reputation Points for meaningful posts

              Comment

              Working...
              X