Results 1 to 4 of 4

Thread: [RESOLVED] [2005] - Add user to group

  1. #1

    Thread Starter
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Resolved [RESOLVED] [2005] - Add user to group

    hello

    i have this code, i'm coding in vista, but the target it's the xp...

    can anyone tell me if this code does the job, create a new user and add the user to the administrators group?

    vb.net Code:
    1. Dim directoria As New DirectoryServices.DirectoryEntry("WinNT://" + Environment.MachineName + ",computer")
    2.             Dim novo_user As DirectoryServices.DirectoryEntry = directoria.Children.Add("User1000", "user")
    3.                 novo_user.CommitChanges()
    4.  
    5.             Dim grupos As DirectoryServices.DirectoryEntry
    6.             grupos = directoria.Children.Find("Administrator", "group")
    7.  
    8.             If grupos.Name <> "" Then
    9.                 MsgBox("Add....")
    10.                 novo_user.Invoke("Add", New Object() {novo_user.Name.ToString})
    11.                 MsgBox("Added.....")
    12.             Else
    13.                 MsgBox("Nothing")
    14.             End If

    In the vista i get an error that the group doesn't exists...
    Last edited by Hack; Sep 19th, 2007 at 06:07 AM. Reason: Fixed Highlight Tags

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [2005] - Add user to group

    If that is the case, then in Vista, it probably doesn't exist.

  3. #3
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2005] - Add user to group

    the group name should be "Administrators" (plural)

  4. #4

    Thread Starter
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: [2005] - Add user to group

    thks solved....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width