#214251 - 2023-06-28 03:41 PM
Re: (NA) Re: Kixtart Getobject Active Directory Issues
[Re: Glenn Barnas]
|
Robdutoit
Hey THIS is FUN
 
Registered: 2012-03-27
Posts: 363
Loc: London, England
|
I have done some more work looking at the GetGroups Function by Howard.
Original GetGroups Function
Function GetGroups($Domain, $Account, optional $Suppress)
; Group Types
; ADS_GROUP_TYPE_GLOBAL_GROUP = 0x00000002,
; ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP = 0x00000004,
; ADS_GROUP_TYPE_LOCAL_GROUP = 0x00000004,
; ADS_GROUP_TYPE_UNIVERSAL_GROUP = 0x00000008,
; ADS_GROUP_TYPE_SECURITY_ENABLED = 0x80000000
;
Dim $Groups[1,0], $i, $x, $Type[8]
$Type[2] = "GLOBAL_GROUP"
$Type[4] = "LOCAL_GROUP"
$Type[8] = "UNIVERSAL_GROUP"
$oAccount=getobject("WinNT://$Domain/$Account,user")
$x = -1
For Each $group In $oAccount.Groups
$x = $x + 1
ReDim Preserve $Groups[1,$x]
; Class is always 'Group'
; $class = $group.Class
$Groups[0,$x] = $group.Name
$Groups[1,$x] = $Type[$group.groupType]
Next
$GetGroups = $Groups
if not $Suppress
$x = ubound($Groups,2)
? $Domain + "\" + $Account + " is a member of " + ($x+1) + " groups."
For $i=0 to $x
? " '" + $Groups[0,$i] + "' (" + $Groups[1,$i] + ")"
Next
Endif
EndFunction
Now Working GetGroups Function
Function GetGroups($Domain, $Account, Optional $Suppress)
Dim $Groups[1, 0], $i, $x
$oAccount = GetObject("WinNT://$Domain/$Account,user")
$x = -1
For Each $group In $oAccount.Groups
$x = $x + 1
ReDim Preserve $Groups[1, $x]
$Groups[0, $x] = $group.Name
Next
; Convert array to string representation
$groupString = ""
For $i = 0 To UBound($Groups, 2) - 1
$groupString = $groupString + $Groups[0, $i] + ","
Next
$groupString = Left($groupString, Len($groupString) - 1)
$GetGroups = $groupString
If Not $Suppress
$x = UBound($Groups, 2)
?$Domain + "\" + $Account + " is a member of " + ($x + 1) + " groups."
For $i = 0 To $x - 1
?" '" + $Groups[0, $i] + "'"
Next
EndIf
EndFunction
I have removed the:
; ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP = 0x00000004, ; ADS_GROUP_TYPE_LOCAL_GROUP = 0x00000004, ; ADS_GROUP_TYPE_UNIVERSAL_GROUP = 0x00000008, ; ADS_GROUP_TYPE_SECURITY_ENABLED = 0x80000000
because most people only use Global Security Groups. I have also removed the Type variable as not relevant here and deleted the extra bit that was on this line ?" '" + $Groups[0, $i] + "'".
I have also added the Convert array to string representation part of the coding.
I am pleased to report that this function is now working too. Once again, it is clear that we need to convert arrays to strings in Kixtart now. The old way doesn't work.
So I have fixed two of the functions on KORG!
I have tried and unfortunately failed to use LDAP in this function. I just cannot get it to return any groups using LDAP no no matter what changes are made to this script. So I have left this as WinNT because at least this works.
I am not sure if maybe Chatgpt could be used in the near future to scan all the user functions submitted on Kixtart website to convert arrays to strings or what the official position that Kixtart will want to take regarding all the udf's that no longer work because of this issue. Most of the coding probably still works, apart from this specific aspect. Having said that, at the moment Chatgpt is able to convert arrays to strings, but even between myself and chatgpt we just can't get some functions using WinNT to use LDAP to work properly. So the free version of Chatgpt is not ready for this task yet. Don't know about the paid for version which I understand is much more advanced. I just highlight this an option to automagically update the UDF's on the KORG using AI as nobody will have the time or interest in manually updating these UDFS. AI is a much better solution to this problem as the task is very specific.
Or failing that, I would recommend adding a note to the main UDF's function page (and highly visible) to make users aware that if they want to use any UDFS with WinNT or LDAP arrays - those arrays need to be converted into strings.
I am going to see if I can trim your script Allen. It works well, but I am sure the coding can be reduced! Will update on this later.
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1446 anonymous users online.
|
|
|