Results 1 to 3 of 3

Thread: [RESOLVED] [2005] Adding a user to a group

  1. #1

    Thread Starter
    Hyperactive Member BrianPaul's Avatar
    Join Date
    Aug 2007
    Posts
    294

    Resolved [RESOLVED] [2005] Adding a user to a group

    I'm trying to add a user to a group. This is a Novell user, but it should be similar to Active Directory. Here's the code I have, but it doesn't seem to work. It returns the user's name, but doesn't add them to the group. Any help would be appreciated!

    vb Code:
    1. Public Class Form1
    2.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    3.         Dim UserAccount As New DirectoryServices.DirectoryEntry("LDAP://172.16.10.151:389/cn=" + TextBox1.Text + ",ou=teachers,o=myOrg", "cn=admin,o=myOrg", "myPassword", DirectoryServices.AuthenticationTypes.FastBind)
    4.         MessageBox.Show(UserAccount.Properties("givenName").Value & " " & UserAccount.Properties("sn").Value)
    5.         UserAccount.Properties("groupMembership").Add("cn=myGroup,OU=teachers,O=myOrg")
    6.     End Sub
    7. End Class

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2005] Adding a user to a group

    Do you get any errors? Also, how certain are you that this should work in the exact same way as AD?
    I dont know how you would do it from the user side of things, I would be more inclined to get the group's DirectoryEntry object and then just use the Invoke method to invoke the "Add" function and add the user that way.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3

    Thread Starter
    Hyperactive Member BrianPaul's Avatar
    Join Date
    Aug 2007
    Posts
    294

    Re: [2005] Adding a user to a group

    Chris, first I want to thank you for the first two lines of the code. You gave me that code about a month ago and I adapted it to work with Novell and it does successfully return the first and last name of the user.

    Second, as soon as you said "did you get errors", I realized my mistake. I didn't get errors and after you mentioned this, I realized that I forgot to commit the changes. I added the following line and now it works!

    UserAccount.CommitChanges()

    Thanks again!

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