Results 1 to 2 of 2

Thread: create home directory while adding user to AD

  1. #1
    Join Date
    Feb 2006
    Posts
    159

    create home directory while adding user to AD

    Can anyone tell me how people are adding new users to AD? Lets say for example: ADUC or VBScripts or any other third party tools? I dont have any issues adding users using AD except for when it came time to change the name of my file server that host each users home directory. I wanted to go to each one of my users account properties and modify the profile tab to change the name of the home directory server. After that simply creating a DNS record for the old server that maps to the ip of the new server would have been my solution except for the old server name needed to be used for another purpose, which is why I wanted to migrate home directories in the first place. Any ideas?

  2. #2
    Join Date
    Jan 2006
    Posts
    7,109
    You should be able to take advantage of multi-object edit capability in ADUC. Apart from that, the script below will handle it by retrieving the list of subfolders of the root home folder on the new server, with assumption that their names match corresponding user accounts, and modify the home directory property of their AD objects accordingly:

    Const ADS_SCOPE_SUBTREE = 2

    sSrvOld = "OldServer"
    sSrvNew = "NewServer"
    sShare = "Users"
    sDomainDN = "'LDAP://dc=domain,dc=com'"

    Set oConn = CreateObject("ADODB.Connection")
    Set oCommand = CreateObject("ADODB.Command")
    oConn.Provider = "ADsDSOObject"
    oConn.Open "Active Directory Provider"
    Set oCommand.ActiveConnection = oConn

    oCommand.Properties("Page Size") = 1000
    oCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set oFolder = oFSO.GetFolder("\\" & sSrvOld & "\" & sShare)
    Set cSubFolders = oFolder.Subfolders

    For Each oSubFolder in csubFolders
    Wscript.Echo oSubFolder.Name
    oCommand.CommandText = "SELECT Name, HomeDirectory, ADsPath FROM " &
    sDomainDN & _
    " WHERE objectCategory ='user'" & _
    " AND samAccountName='" & oSubFolder.Name & "'"
    Set oRecordSet = oCommand.Execute
    oRecordSet.MoveFirst
    Do Until oRecordSet.EOF
    Set oUser = GetObject(oRecordSet.Fields("ADsPath").Value)
    oUser.HomeDirectory = Replace(oRecordSet.Fields("HomeDirectory").Value,
    sSrvOld, sSrvNew, vbTextCompare)
    oUser.SetInfo
    oRecordSet.MoveNext
    Loop
    Next

    You can also find some sample scripts at
    http://www.microsoft.com/technet/scr....mspx?mfr=true

Similar Threads

  1. 2003 AD user looses rights to home directory
    By jwhite4343 in forum Active Directory
    Replies: 2
    Last Post: 27-03-2012, 12:33 AM
  2. Force PAM to create new user home folder in Debian Linux
    By tHeDa! in forum Operating Systems
    Replies: 3
    Last Post: 01-03-2012, 10:34 AM
  3. How to create New User Profile in Windows XP Home ?
    By Omprakash in forum Operating Systems
    Replies: 2
    Last Post: 26-02-2009, 10:52 AM
  4. user loses mapped home directory
    By Eigenberg in forum Windows XP Support
    Replies: 17
    Last Post: 08-12-2008, 05:47 PM
  5. Replies: 5
    Last Post: 13-06-2007, 07:23 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,727,063,657.58636 seconds with 18 queries