Results 1 to 4 of 4

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

Threaded View

  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

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