PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms..win.server.scripting > Re: query to remove only certain groups of a user
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Re: query to remove only certain groups of a user

Réponse
 
LinkBack Outils de la discussion
Vieux 17/09/2007, 14h13   #1 (permalink)
Richard Mueller [MVP]
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: query to remove only certain groups of a user

preetham wrote:

> i need to write a script that will remove only few groups of a user from
> AD.
>
> any in this matter would be great.


You cannot modify AD objects with a query. You will need to bind to AD
objects to make changes. The method I prefer to remove a user from a group
would be similar to below:
================
' Bind to the user object.
Set objUser = GetObject("LDAP://cn=Jim Smith,ou=West,dc=MyDomain,dc=com")

' Bind to the group object.
Set objGroup = GetObject("LDAP://cn=TestGroup,ou=East,dc=MyDomain,dc=com")

' Check if user a member of the group.
If (objGroup.IsMember(objUser.AdsPath) = True) Then
' Remove user from group.
objGroup.Remove(objUser.AdsPath)
End If

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--


  Réponse avec citation
Vieux 19/09/2007, 10h42   #2 (permalink)
preetham
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: query to remove only certain groups of a user

HI Richard,

if i want to remove only certain group membership of a user will the
below given option work

what i mean is lets say is user U1 is a member of groups G1,G2, G3, G4 and
G5. when i disable the user i want all the groups except G3 to be removed.
can this be done?

"preetham" wrote:

> Thanks for you richard
>
> "Richard Mueller [MVP]" wrote:
>
> > preetham wrote:
> >
> > > i need to write a script that will remove only few groups of a user from
> > > AD.
> > >
> > > any in this matter would be great.

> >
> > You cannot modify AD objects with a query. You will need to bind to AD
> > objects to make changes. The method I prefer to remove a user from a group
> > would be similar to below:
> > ================
> > ' Bind to the user object.
> > Set objUser = GetObject("LDAP://cn=Jim Smith,ou=West,dc=MyDomain,dc=com")
> >
> > ' Bind to the group object.
> > Set objGroup = GetObject("LDAP://cn=TestGroup,ou=East,dc=MyDomain,dc=com")
> >
> > ' Check if user a member of the group.
> > If (objGroup.IsMember(objUser.AdsPath) = True) Then
> > ' Remove user from group.
> > objGroup.Remove(objUser.AdsPath)
> > End If
> >
> > --
> > Richard Mueller
> > Microsoft MVP Scripting and ADSI
> > Hilltop Lab - http://www.rlmueller.net
> > --
> >
> >
> >

  Réponse avec citation
Vieux 19/09/2007, 18h58   #3 (permalink)
Richard Mueller [MVP]
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: query to remove only certain groups of a user

Yes, you can just remove the group memberships you want and leave the rest.
You would repeat the "If/Then/End If" structure for each group membership to
be removed. It requires binding to each group whose membership will be
modified.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--

"preetham" <preetham@discussions.microsoft.com> wrote in message
news:1E747958-3C2E-40FC-9F9F-5D42863D7B23@microsoft.com...
> HI Richard,
>
> if i want to remove only certain group membership of a user will the
> below given option work
>
> what i mean is lets say is user U1 is a member of groups G1,G2, G3, G4 and
> G5. when i disable the user i want all the groups except G3 to be removed.
> can this be done?
>
> "preetham" wrote:
>
>> Thanks for you richard
>>
>> "Richard Mueller [MVP]" wrote:
>>
>> > preetham wrote:
>> >
>> > > i need to write a script that will remove only few groups of a user
>> > > from
>> > > AD.
>> > >
>> > > any in this matter would be great.
>> >
>> > You cannot modify AD objects with a query. You will need to bind to AD
>> > objects to make changes. The method I prefer to remove a user from a
>> > group
>> > would be similar to below:
>> > ================
>> > ' Bind to the user object.
>> > Set objUser = GetObject("LDAP://cn=Jim
>> > Smith,ou=West,dc=MyDomain,dc=com")
>> >
>> > ' Bind to the group object.
>> > Set objGroup =
>> > GetObject("LDAP://cn=TestGroup,ou=East,dc=MyDomain,dc=com")
>> >
>> > ' Check if user a member of the group.
>> > If (objGroup.IsMember(objUser.AdsPath) = True) Then
>> > ' Remove user from group.
>> > objGroup.Remove(objUser.AdsPath)
>> > End If
>> >
>> > --
>> > Richard Mueller
>> > Microsoft MVP Scripting and ADSI
>> > Hilltop Lab - http://www.rlmueller.net
>> > --
>> >
>> >
>> >



  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 01h43.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10061 seconds with 11 queries