Announcement

Collapse
No announcement yet.

Create user with home folder

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

  • Create user with home folder

    Dear All,

    I have been trying to create user with vb6, but I have some problem, they are :
    1. User can not map to his home folder with error:
    "cannot find the file "\\nastwin2003s\user1\use1 test1$" (or one of its components). Make sure the path and file name are correct and tha all required libraries are available"
    Whereas the home folder have been available on my file server and I already grant him with full control access.

    2. If I right click the folder and click properties ---> click security tab, I got error:
    "the permission on "foder name" are incorrectly ordered, which may cause some entries to be ineffective.
    Press OK to continue and sort the permission correctly, or Cancel to reset the permission."


    I hope your help.

    Thanks,
    nast

    Below the coding:

    Code:
    Private Sub Command3_Click()
    
    Dim oOU, oUser, oMailbox
    user = "user1"
    surename = "user1"
    lastname = "test1"
    password = "Pa$$w0rd"
    
    Set oOU = GetObject("LDAP://OU=Test,OU=Users,OU=NAST,DC=win2003,DC=nast")
    Set oUser = oOU.Create("user", "CN=" & surename & " " & lastname)
      oUser.Put "sAMAccountName", surename & " " & lastname
      oUser.Put "displayName", surename & " " & lastname
      oUser.Put "name", surename & " " & lastname
      oUser.Put "givenName", surename
      oUser.Put "sn", lastname
      oUser.Put "title", "title user1"
      oUser.Put "homeDirectory", "\\nastwin2003s\User1\" & surename & " " & lastname & "$"
      oUser.Put "description", "Desc user 1"
      oUser.Put "physicalDeliveryOfficeName", "Jakarta"
      oUser.Put "telephoneNumber", 9999
      oUser.Put "department", "Dept User1"
      oUser.Put "company", "Company User1"
      oUser.Put "homeDrive", "H:"
      oUser.Put "scriptPath", "Ind.bat"
      oUser.Put "mail", "[email protected]"
      'oUser.Put "memberOf", "CN=web-master,CN=Users,DC=win2003,DC=nast"
      oUser.Put "userPrincipalName", surename & " " & lastname & "@win2003.nast"
      oUser.SetInfo
      oUser.SetPassword password
      oUser.AccountDisabled = False
      oUser.SetInfo
      
      ' create home folder and add permission
    
    Dim objFSO, objFolder, objShell, strDirectory
    Dim sUserName As String
    Dim sFolderName As String
        sUserName = Trim$(surename & " " & lastname)
        sFolderName = Trim$("\\nastwin2003s\User1\ " & surename & " " & lastname & "$")
    strDirectory = sFolderName
    
    ' Create the File System Object
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    ' Note If..Exists. Then, Else ... End If construction
    If objFSO.FolderExists(strDirectory) Then
       Set objFolder = objFSO.GetFolder(strDirectory)
      
    Else
       Set objFolder = objFSO.CreateFolder(strDirectory)
    
    End If
    
    
        SetAccess sUserName, sFolderName, GENERIC_ALL
        
      
      Const ADS_PROPERTY_APPEND = 3
     
    Set objGroup = GetObject _
      ("LDAP://cn=Phone Users,ou=Groups,ou=nast,dc=win2003,dc=nast")
     
    objGroup.PutEx ADS_PROPERTY_APPEND, "member", _
        Array("cn=user1 test1,ou=Test,ou=Users,ou=nast,dc=win2003,dc=nast")
     
    objGroup.SetInfo
    MsgBox ("apend users finished")
    
    End Sub

    module1:
    Please visit here http://www.tek-tips.com/viewthread.cfm?qid=460090 for coding.
    Because if I copy the coding here is more than 10.000 character.
    Last edited by biggles77; 26th December 2009, 05:49. Reason: Wrap script in CODE tag

  • #2
    Re: Create user with home folder

    any one help me please!

    Comment


    • #3
      Re: Create user with home folder

      Dont bump posts please -- you will get an answer when someone has one, and it is the holiday season

      From a quick look at your post, the name of the home directory has two problems:
      1) the $ should be after the base directory (this is the one you shared, isnt it) so:
      \\nastwin2003s\User1$\
      2) You have numerous spaces which always cause problems with file paths. Remove them if possible
      Tom Jones
      MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
      PhD, MSc, FIAP, MIITT
      IT Trainer / Consultant
      Ossian Ltd
      Scotland

      ** Remember to give credit where credit is due and leave reputation points where appropriate **

      Comment


      • #4
        Re: Create user with home folder

        Originally posted by Ossian View Post
        Dont bump posts please -- you will get an answer when someone has one, and it is the holiday season

        From a quick look at your post, the name of the home directory has two problems:
        1) the $ should be after the base directory (this is the one you shared, isnt it) so:
        \\nastwin2003s\User1$\
        2) You have numerous spaces which always cause problems with file paths. Remove them if possible
        Thanks for your reply
        And I'am sorry for my bump post, exactly, I just mean update my post.

        1. \\nastwin2003s\user1\user1 test1$
        user1 = share folder
        user1 test1$ = user's home folder

        2. I removed the space form the path to be \\nastwin2003s\user1\user1
        But the problem still occured.

        I hope some one can help me, still now, I have not found the solution yet.

        Regards,
        nast

        Comment


        • #5
          Re: Create user with home folder

          Thanks Ossian,

          Problem no. 1 solved, but no.2 still occured.
          I found space at line sFolderName = Trim$("\\nastwin2003s\User1\ " & surename & " " & lastname & "$")

          and I found solution for no. 2 at http://support.microsoft.com/default...b;en-us;825751

          But, the coding is vbscript not VB6, do you have reference for vb6.

          Thanks,
          nast

          Comment


          • #6
            Re: Create user with home folder

            Try the same code -- vbscript and VB6 are very similar!
            Tom Jones
            MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
            PhD, MSc, FIAP, MIITT
            IT Trainer / Consultant
            Ossian Ltd
            Scotland

            ** Remember to give credit where credit is due and leave reputation points where appropriate **

            Comment

            Working...
            X