Remove A User From A Group

  • Thread starter Thread starter Ram
  • Start date Start date
R

Ram

Hey,
I'v got a group in ActiveDirectory that has about 2000 members.
I want to remove a certain user from that group.
When I tried to remove it using the group's DirectoryEntry:
usersGroup.Children.Remove(userEntry) I get the following exception:
"Cannot Remove The Specified Item Because It Was Not Found In The Specified
Collection".
When I looked at the group's "Member" collection in the debug window, I saw
only the first 1500 results - all the other 500 and so users (among them the
user I tried to remove from that group) were not on that list.
I know for sure that the other 500 users are on that group because when I
look at the - "MemberOf" property of that users,
I get - among other groups - the current group.
Is there another way of doing so, that is not limited to a nomerouse number
of users?
Thanks ahead

--Ram
 
I'v got a group in ActiveDirectory that has about 2000 members.
I want to remove a certain user from that group.
When I tried to remove it using the group's DirectoryEntry:
usersGroup.Children.Remove(userEntry) I get the following exception:
"Cannot Remove The Specified Item Because It Was Not Found In The Specified
Collection".

there's a flaw in the system.directoryservices components for groups
with large number of members. one workaround is to use the native adsi
components instead.

marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
Hey,
Thanks for the reply!
How can I use the native adsi instead?
Would:
dim userGroups as IadsGroups
userGroups = GetObject("MyGroupDN")
userGroups.Remove("MyUserDN")
userGroups.SetInfo()
- This work?
Thanks ahead

--Ram
 
How can I use the native adsi instead?
Would:
dim userGroups as IadsGroups
userGroups = GetObject("MyGroupDN")
userGroups.Remove("MyUserDN")
userGroups.SetInfo()
- This work?

Yes - add some error checking (e.g. check if the dim userGroup as
IADsGroup has succeeded), but then you should be okay, I think.

Marc

================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
Back
Top