#175557 - 2007-04-20 05:13 PM
ComputerInGroup Cache?
|
tylan
Starting to like KiXtart
Registered: 2005-11-17
Posts: 115
Loc: Johnstown, PA
|
Is there a way to boost the performance of the ComputerInGroup UDF? Is there a way (or a better option)to not have to query AD multiple times during the logon process? The computer group membership doesn't change during the logon process, so is there a way to cache the computer's memberships?
I'd like something similar to the way the InGroup function was updated w/ kix 4.x where the group-membership cache is stored in the registry hive of the current user and contains security-identifier-to-groupname mappings.
Thanks Tylan
|
|
Top
|
|
|
|
#175589 - 2007-04-23 07:19 PM
Re: ComputerInGroup Cache?
[Re: Les]
|
tylan
Starting to like KiXtart
Registered: 2005-11-17
Posts: 115
Loc: Johnstown, PA
|
fnInGroupAD() doesn't seem much different, it's just using LDAP for the query.
Thanks anyways.
|
|
Top
|
|
|
|
#175595 - 2007-04-23 08:34 PM
Re: ComputerInGroup Cache?
[Re: Chris S.]
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Something like...
$groups = fnInGroup()
For Each $G in $Groups
$G ?
Next
Get $
Function fnInGroup(Optional $bComputer)
Dim $objSys,$objTarget,$aMemberOf,$sMemberOf,$i
$objSys = CreateObject("ADSystemInfo")
$objTarget = GetObject("LDAP://"+Iif($bComputer,$objSys.ComputerName,$objSys.UserName))
$aMemberOf = $objTarget.GetEx("memberOf")
Dim $aGroups[UBound($aMemberOf)]
For Each $sMemberOf in $aMemberOf
$aGroups[$i] = Split(Split($sMemberOf,"CN=")[1],",")[0]
$i = $i + 1
Next
$fnInGroup = $aGroups
EndFunction
|
|
Top
|
|
|
|
#175987 - 2007-05-04 08:40 PM
Re: ComputerInGroup Cache?
[Re: Chris S.]
|
tylan
Starting to like KiXtart
Registered: 2005-11-17
Posts: 115
Loc: Johnstown, PA
|
How would I use your code to map printers based on group membership?
|
|
Top
|
|
|
|
#175989 - 2007-05-04 08:48 PM
Re: ComputerInGroup Cache?
[Re: tylan]
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Read through the entire thread. I thnk it has what you are looking for...
Create AD Global Groups for printer objects
More related discussion of groups and printers: Primary computer group membership
Edited by Howard Bullock (2007-05-04 09:03 PM) Edit Reason: Added content
|
|
Top
|
|
|
|
#175993 - 2007-05-04 09:20 PM
Re: ComputerInGroup Cache?
[Re: Howard Bullock]
|
tylan
Starting to like KiXtart
Registered: 2005-11-17
Posts: 115
Loc: Johnstown, PA
|
I think I was over thinking this...
$groups = fnInGroup(@WKSTA)
For Each $Group in $Groups
IF $Group = "PARSTDCOMPUTERS"
?"Do Stuff"
ENDIF
IF $Group = "BUSINESS_OFFICE_PRINTER_COMPUTERS"
?"Do More stuff"
ENDIF
Next
Get $
Function fnInGroup(Optional $bComputer)
Dim $objSys,$objTarget,$aMemberOf,$sMemberOf,$i
$objSys = CreateObject("ADSystemInfo")
$objTarget = GetObject("LDAP://"+Iif($bComputer,$objSys.ComputerName,$objSys.UserName))
$aMemberOf = $objTarget.GetEx("memberOf")
Dim $aGroups[UBound($aMemberOf)]
For Each $sMemberOf in $aMemberOf
$aGroups[$i] = Split(Split($sMemberOf,"CN=")[1],",")[0]
$i = $i + 1
Next
$fnInGroup = $aGroups
EndFunction
So, this code would be more efficient than checking AD 25+ time for computer group membership?
|
|
Top
|
|
|
|
#175994 - 2007-05-04 09:39 PM
Re: ComputerInGroup Cache?
[Re: tylan]
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
A SELECT...CASE...ENDSELECT would be more efficient. Once a match is found, the other conditions are not checked. Place the largest group at the top and add them in descending order by members.
Edited by Howard Bullock (2007-05-04 09:40 PM)
|
|
Top
|
|
|
|
#175995 - 2007-05-04 09:45 PM
Re: ComputerInGroup Cache?
[Re: Howard Bullock]
|
tylan
Starting to like KiXtart
Registered: 2005-11-17
Posts: 115
Loc: Johnstown, PA
|
Cool. Will do.
Since no one ever corrected me... I'm assuming that the ComputerInGroup UDF is not efficient if you are going to run it 20 - 30 times in a row.
|
|
Top
|
|
|
|
#175998 - 2007-05-04 10:11 PM
Re: ComputerInGroup Cache?
[Re: Les]
|
tylan
Starting to like KiXtart
Registered: 2005-11-17
Posts: 115
Loc: Johnstown, PA
|
Oh... I guess he did confirm that running the UDF multiples times was inefficient.
|
|
Top
|
|
|
|
#176001 - 2007-05-04 11:59 PM
Re: ComputerInGroup Cache?
[Re: tylan]
|
tylan
Starting to like KiXtart
Registered: 2005-11-17
Posts: 115
Loc: Johnstown, PA
|
Chris, Why did you use LDAP for your code? Instead of ADSI? Is ADSI a quicker lookup?
Edited by tylan (2007-05-08 03:17 PM)
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|