#40212 - 2003-05-15 02:40 PM
Re: Delete all Groups from users group membership list
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Isn't this something that LDIFE or CSVDE handles? Kinda like the old Reskit tool ADDUSERS? Or, are you asking to remove all groups from say a specific user, but keep the Account on the domain?
Kent
|
|
Top
|
|
|
|
#40213 - 2003-05-15 02:46 PM
Re: Delete all Groups from users group membership list
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Actually, I think the task would not be above your technical skill level.
Try it and see.
Use EnumGroup() and EnumLocalGroup() (if req.) to enumerate the groups to which the user is a member. Examples are in the manual and on the board.
For each group name $grp = GetObject(winnt://domain/groupname). Remove the user $grp.remove(Winnt://domain/user) [ 15. May 2003, 14:46: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#40215 - 2003-05-15 02:48 PM
Re: Delete all Groups from users group membership list
|
Richie19Rich77
Seasoned Scripter
   
Registered: 2002-08-16
Posts: 624
Loc: London, England
|
Thanks Howard
Just need that little nudge, makes sense I will look into it.
Thanks
|
|
Top
|
|
|
|
#40216 - 2003-05-15 02:57 PM
Re: Delete all Groups from users group membership list
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Also, you can do a simple ADSI script...
code:
Break On CLS
$sUser = "Test"
$objUser=GetObject("WinNT://"+@DOMAIN+"/"$sUser) "Groups for " $objUser.Name ? For Each $objGroup in $objUser.Groups $objGroup.Name " - " $objGroup.Description ? $objGroup.Remove ($objUser.AdsPath) Next
|
|
Top
|
|
|
|
#40217 - 2003-05-15 02:59 PM
Re: Delete all Groups from users group membership list
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
BTW, the above sample script removes the user from all groups except Domain Users.
|
|
Top
|
|
|
|
#40219 - 2003-05-15 03:02 PM
Re: Delete all Groups from users group membership list
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Chris, that looks awful familiar. Did you or I post that previously?
|
|
Top
|
|
|
|
#40220 - 2003-05-15 03:05 PM
Re: Delete all Groups from users group membership list
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Hmm. Well, its just a one line add to enuming through a user's (or with slight mod, computer's) group membership.
Pretty basic stuff really. I can't think of too many ways (that make sense) to do it differently.
|
|
Top
|
|
|
|
#40221 - 2003-05-15 03:23 PM
Re: Delete all Groups from users group membership list
|
Richie19Rich77
Seasoned Scripter
   
Registered: 2002-08-16
Posts: 624
Loc: London, England
|
One problem ENUMGROUP works with the current user, I want to delete the list of groups for $x user.
Just when you thought it was nice and easy. Rich
|
|
Top
|
|
|
|
#40225 - 2003-05-15 03:32 PM
Re: Delete all Groups from users group membership list
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Richard, see what you happens when you ask for help.
|
|
Top
|
|
|
|
#40226 - 2003-05-15 04:04 PM
Re: Delete all Groups from users group membership list
|
Richie19Rich77
Seasoned Scripter
   
Registered: 2002-08-16
Posts: 624
Loc: London, England
|
Hi Guys
I have converted it to use LDAP connection instaed of WinNT.
So simple when you get some help :-)
Thanks
code:
$objUser = GetObject("LDAP://" +$TranslateUserName[0]) For Each $objGroup in $objUser.Groups $objGroup.Remove ($objUser.AdsPath) Next
[ 15. May 2003, 16:08: Message edited by: Richard Farthing ]
|
|
Top
|
|
|
|
#40227 - 2003-05-15 04:09 PM
Re: Delete all Groups from users group membership list
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Cool. BTW, you can still use the WinNT provider in with an AD network (we just converted to AD last weeked). My example will work on either an NT4 or AD network.
|
|
Top
|
|
|
|
#40229 - 2003-05-15 05:52 PM
Re: Delete all Groups from users group membership list
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
The only caveat I could think of with this...
If you remove all groups from a user, that also includes "Domain Users" you may run into conflicts with your application set.
If you remove them from the group, then the point is moot.
BTW, did you know that you can achieve alot of this with the "query" functionality of AD Users and computers in XP? You can save the queries and export the data too.
Cheers!
Kent
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 657 anonymous users online.
|
|
|