|
-
Jan 26th, 2009, 05:04 PM
#1
Thread Starter
Hyperactive Member
[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:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
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)
MessageBox.Show(UserAccount.Properties("givenName").Value & " " & UserAccount.Properties("sn").Value)
UserAccount.Properties("groupMembership").Add("cn=myGroup,OU=teachers,O=myOrg")
End Sub
End Class
-
Jan 26th, 2009, 07:48 PM
#2
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.
-
Jan 26th, 2009, 08:26 PM
#3
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|