Page 1 of 1 1
Topic Options
#139071 - 2005-05-03 05:10 PM Question about ComputerInGroup
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
I am still hashing out my global login script and one of the items that I plan on including is the SMS installation portion of the login script. I wanted to create a mechanism to exclude systems or users from installing SMS during the login process. One of the things that hit me is this:

Say we have 10 OUs - one for each site, each with their own policies, etc. I created a group called [OU]_SMS_EXCLUSION under each OU, as the admins for each site only have the ability to manipulate their own sites. I then created a Global Group called [Company]_SMS_EXCLUSION and added the other groups as members. I then added a test machine into it's local SMS exclusion group. In my script, I am using the ComputerInGroup UDF, and for some reason, if I search for the local group it works fine, but it does not work if I search against the global group, of which the local group is a member.

Can .KIX not see that far?

Any help would be appreciated.


Edited by oobnuker (2005-05-03 05:59 PM)
_________________________
-- oobnuker - .KIX hack - no really.

Top
#139072 - 2005-05-03 06:02 PM Re: Question about ComputerInGroup
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Here is the code snippet to chew on:
Code:

Function ComputerInGroup($group,optional $Domain)
Dim $oGrp
if not $domain $domain=@domain EndIf
$oGrp = GetObject("WinNT://" + $domain + "/" + $group + ",group" )
if @error exit 1 EndIf

if $oGrp.IsMember("WinNT://" + $domain + "/" + @wksta + "$$" )
$ComputerInGroup=1
else
$ComputerInGroup=0
endif
EndFunction

If ComputerInGroup('PREMCOR_SMS_EXCLUSION')=1
? 'Computer will not install SMS'
Else
? 'Computer will install SMS'
EndIf

Sleep 5



Where PREMCOR_SMS_EXCLUSION is a Global Group that only contains the local groups. This does not work.

If I exchange PREMCOR_SMS_EXCLUSION for HQ_SMS_EXCLUSION - which is the local group for HQ, of which the computer is a member, the script works fine.

Am I making sense?
_________________________
-- oobnuker - .KIX hack - no really.

Top
#139073 - 2005-05-04 08:44 PM Re: Question about ComputerInGroup
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Anybody have anything to say about this? Basically, nested groups do not work for some reason.
_________________________
-- oobnuker - .KIX hack - no really.

Top
#139074 - 2005-05-04 08:53 PM Re: Question about ComputerInGroup
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
What do you want us to say that you haven't already said? If you look at the code, you can see it does not do nested groups. You would have to rewrite it, or talk nice to someone to rewrite it for you.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#139075 - 2005-05-04 08:55 PM Re: Question about ComputerInGroup
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Quote:

What do you want us to say that you haven't already said? If you look at the code, you can see it does not do nested groups. You would have to rewrite it, or talk nice to someone to rewrite it for you.




Well, in all my searching, I never found a definite answer to my question, that's why I posed it again. I wanted some sort of confirmation that this is "by design" or limitation, and not something that I am doing wrong...that's all.
_________________________
-- oobnuker - .KIX hack - no really.

Top
#139076 - 2005-05-04 09:26 PM Re: Question about ComputerInGroup
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
This code is written using the the NT4 compatible WinNT:// ADSI provider. If you want to understand nested group memberships, then someone needs to investigate other methods Microsoft has to check group membership. If I get time, I may sift throught MSDN.microsoft.com to see if the LDAP ADSI provider support this. If Microsoft can perform this task, there is usually way for us to access that functionality.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#139077 - 2005-05-04 09:41 PM Re: Question about ComputerInGroup
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Quote:

This code is written using the the NT4 compatible WinNT:// ADSI provider. If you want to understand nested group memberships, then someone needs to investigate other methods Microsoft has to check group membership. If I get time, I may sift throught MSDN.microsoft.com to see if the LDAP ADSI provider support this. If Microsoft can perform this task, there is usually way for us to access that functionality.




Thanks. I think a lot of people would like this.
_________________________
-- oobnuker - .KIX hack - no really.

Top
#139078 - 2005-05-04 09:43 PM Re: Question about ComputerInGroup
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The question is why nest local groups in global groups in this case? Unless the local group is on a different resource than the global group, it makes no sense.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#139079 - 2005-05-04 09:50 PM Re: Question about ComputerInGroup
oobnuker Offline
Getting the hang of it

Registered: 2003-12-09
Posts: 87
Loc: Oxford, CT
Quote:

The question is why nest local groups in global groups in this case? Unless the local group is on a different resource than the global group, it makes no sense.




For me, I am trying to exclude the SMS client from being installed in the login script if a computer is a member of a certain group. At my site, each physical location only has the ability to manipulate users and computers in their own OU. So I made a global group PREMCOR_SMS_EXCLUSION, and then created local groups [SITE]_SMS_EXCLUSION under each OU for the local admins to use, with the local groups members of the global group. If this functionality existed, I could do something like:

Code:

if computeringroup('PREMCOR_SMS_EXCLUSION')
Skip SMS
else
Install SMS
endif



but instead, my if computeringroup line is off the charts having to include 10 individual OUs. Also, I consider our site to be relatively small, so I can imagine that the value of nested groups would increase with a larger site.

Maybe I am doing something wrong or overlooking something, but this is all I've got right now.


Edited by oobnuker (2005-05-04 09:51 PM)
_________________________
-- oobnuker - .KIX hack - no really.

Top
#139080 - 2005-05-04 10:40 PM Re: Question about ComputerInGroup
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I guess if you are using groups to delegate tasks and the logon is managed centrally, it makes sense. In our company, there is no centrally managed logon scripts. Each division manager their own as they do their SMS server.

This is drifting a little off topic, but we decided to push out SMS through discovery instead of logon script. We control what computers to exclude one of two ways. One way is to add their NetBIOS names to "ExcludeServers" in the SMS_DISCOVERY_DATA_MANAGER key. The other way is to not add the SMS server's account to the local administrators group.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#139081 - 2005-05-04 10:41 PM Re: Question about ComputerInGroup
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
I think from what i remember, ADSI does not support nested groups. I haven't had a chance to test it but have you tried just using LDAP for the query

(pseudo code)
Code:

if Getobject(AdsPathOfTheGroup).IsMember(AdsPathOfTheMachine)
; Exclude from SMS
else
; Install SMS
endif


Top
#139082 - 2005-05-05 02:55 PM Re: Question about ComputerInGroup
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
This does not make me happy.

From MSDN:
Quote:


Determining a User's or Group's Membership in a Group
The IADsGroup.IsMember method can be used to determine if an object is a member of a group. This method returns TRUE if the specified object is a direct member of the group, that is, the group's member property contains the specified object.

A group can contain other groups. The IADsGroup.IsMember method does not recursively verify the members of groups in its member property, groups within those groups, and so on. To recursively verify that an object is a member of a group, enumerate the groups in the member property, verify the members of those groups to see if the object is a member, and if those groups contain other groups, check their members, and so on.





If you were to use a local group as parent SMS group, then this should be possible. In Perl I can use NetUserGetLocalGroups("", $user, &LG_INCLUDE_INDIRECT, \@groups) to get a list of all local groups the including indirect memberships from nested global groups.

http://msdn.microsoft.com/library/defaul...localgroups.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/iadsuser_groups.asp

I am testing the IADsUser::Groups functionality to see if the it lists my local group membership by indirect membership in a nested global group. Back in a view minutes.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#139083 - 2005-05-05 03:41 PM Re: Question about ComputerInGroup
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
No joy with the ADSI.

But this may work for you. It is not as clean as I would like but...
Code:
Function InstallSMS()
; Create global groups in each OU using the naming format "OUname_NO_SMS"
; Add computers to these groups that do not get SMS

Dim $Install_SMS
$Install_SMS = 1

$oComputer = GetObject("WinNT://domain/" + @wksta + "$" + ",user")
$GrpArray = $oComputer.Groups
For Each $grp In $GrpArray
if Right($grp,6) = "NO_SMS"
$Install_SMS = 0
endif
Next

If $Install_SMS
;do something...
Endif
Endfunction



Fixed blatant screwup in object names.


Edited by Howard Bullock (2005-05-05 04:02 PM)
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#139084 - 2005-05-05 03:56 PM Re: Question about ComputerInGroup
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I think that is untested, no?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#139085 - 2005-05-05 03:58 PM Re: Question about ComputerInGroup
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I guess I should have stated that. I just quickly coded it for discussion and testing by those interested.

I did test the group listing loop with a standard user as a proof of concept to myself.


Edited by Howard Bullock (2005-05-05 03:58 PM)
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#139086 - 2005-05-05 04:00 PM Re: Question about ComputerInGroup
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I just can't see how that can work. You instantiate the COM object with the handle $oComputer but then later, you have $usr.Groups ???
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#139087 - 2005-05-05 04:01 PM Re: Question about ComputerInGroup
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
K, caught the rewrite.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 871 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.069 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org