Recipe 6.29 Setting a User's Profile Attributes6.29.1 ProblemYou want to set one or more of the user profile attributes. 6.29.2 Solution6.29.2.1 Using a graphical user interface
6.29.2.2 Using a command-line interface> dsmod user "<UserDN>" -loscr <ScriptPath> -profile <ProfilePath> -hmdir[RETURN] <HomeDir> -hmdrv <DriveLetter> 6.29.2.3 Using VBScript' This code sets the various profile related attributes for a user. strUserDN = "<UserDN>" ' e.g. cn=jsmith,cn=Users,dc=rallencorp,dc=com set objUser = GetObject("LDAP://" & strUserDN) objUser.Put "homeDirectory", "\\fileserver\" & objUser.Get("sAMAccountName") objUser.Put "homeDrive", "z:" objUser.Put "profilePath", "\\fileserver\" & _ objUser.Get("sAMAccountName") & "\profile" objUser.Put "scriptPath", "login.vbs" objUser.SetInfo Wscript.Echo "Profile info for " & objUser.Get("sAMAccountName") & " updated" 6.29.3 DiscussionThe four attributes that make up a user's profile settings include the following:
When you set the homeDirectory attribute, the folder being referenced needs to already exist. For an example on creating shares for users, see MS KB 234746. 6.29.4 See AlsoMS KB 234746 (How to Create User Shares for All Users in a Domain with ADSI), MS KB 271657 (Scripted Home Directory Paths Require That Folders Exist), and MS KB 320043 (HOW TO: Assign a Home Directory to a User) |