added sysprog entities
This commit is contained in:
73
SYSPROG/STPROC/IFX_LDAP_GROUPS_FOR_USER.txt
Normal file
73
SYSPROG/STPROC/IFX_LDAP_GROUPS_FOR_USER.txt
Normal file
@ -0,0 +1,73 @@
|
||||
Compile Function IFX_LDAP_GROUPS_FOR_USER(inUser, inDomain)
|
||||
|
||||
$Insert REVDOTNETEQUATES
|
||||
|
||||
Declare subroutine Set_Property.Net
|
||||
Declare Function Active_Directory_Services, Unassigned, RetStack, GetNetworkUsername
|
||||
|
||||
Ans = ''
|
||||
If Not(Unassigned(inUser)) Then
|
||||
If Unassigned(inUser) Then inUser = ''
|
||||
If inUser = '' Then inUser = GetNetworkUsername()
|
||||
If Unassigned(inDomain) Then inDomain = ''
|
||||
If inDomain Eq '' Then inDomain = Active_Directory_Services('GetComputerDomain')
|
||||
Domain = inDomain
|
||||
Username = inUser
|
||||
ADGroups = ''
|
||||
DotNetHandle = StartDotNet("","4.0")
|
||||
DotNetDir = CheckDotNet('4.0'):'\'
|
||||
AccountMgmtDllPath = DotNetDir:'System.DirectoryServices.AccountManagement.dll'
|
||||
Set_Property.Net(DotNetHandle, "AssemblyName", AccountMgmtDllPath)
|
||||
If Not(Get_Status(errCode)) then
|
||||
Params = 'Domain':@FM:Domain
|
||||
ParamTypes = 'System.DirectoryServices.AccountManagement.ContextType':@FM:'System.String'
|
||||
objPC = Create_Class.Net(DotNetHandle, "System.DirectoryServices.AccountManagement.PrincipalContext", 0, Params, ParamTypes)
|
||||
If Not(Get_Status(errCode)) then
|
||||
objUserPrincipal = Create_Class.Net(DotNetHandle, "System.DirectoryServices.AccountManagement.UserPrincipal", 0, objPC, 'RevDotNet')
|
||||
If Not(Get_Status(errCode)) then
|
||||
Set_Property.Net(objUserPrincipal, 'Name', Username)
|
||||
objPrinSearcher = Create_Class.Net(DotNetHandle, "System.DirectoryServices.AccountManagement.PrincipalSearcher", 0, objUserPrincipal, 'RevDotNet')
|
||||
If Not(Get_Status(errCode)) then
|
||||
objPrin = Send_Message.Net(objPrinSearcher, 'FindOne', '', '', 1)
|
||||
If Not(Get_Status(errCode)) then
|
||||
Name = Get_Property.Net(objPrin, 'Name', 0)
|
||||
objPrinSearchResult = Send_Message.Net(objPrin, 'GetGroups', '', '', 1)
|
||||
If Not(Get_Status(errCode)) then
|
||||
objEnum = Send_Message.Net(objPrinSearchResult, 'GetEnumerator', '', '', 1)
|
||||
If Not(Get_Status(errCode)) then
|
||||
Loop
|
||||
Done = Send_Message.Net(objEnum, 'MoveNext', '', '', 0)
|
||||
Until Done EQ 'False'
|
||||
If Not(Get_Status(errCode)) then
|
||||
objCurrPrin = Get_Property.Net(objEnum, 'Current', 1)
|
||||
If Not(Get_Status(errCode)) then
|
||||
CurrPrinName = Get_Property.Net(objCurrPrin, 'Name', 0)
|
||||
If CurrPrinName NE 'Domain Users' then
|
||||
Locate CurrPrinName in ADGroups using @FM setting fPos else
|
||||
ADGroups<-1> = CurrPrinName
|
||||
end
|
||||
end
|
||||
Free_Class.Net(objCurrPrin)
|
||||
end
|
||||
end
|
||||
Repeat
|
||||
Free_Class.Net(objEnum)
|
||||
end
|
||||
Free_Class.Net(objPrinSearchResult)
|
||||
end
|
||||
Free_Class.Net(objPrin)
|
||||
end
|
||||
Free_class.Net(objPrinSearcher)
|
||||
end
|
||||
Free_Class.Net(objUserPrincipal)
|
||||
end
|
||||
Free_Class.Net(objPC)
|
||||
end
|
||||
End
|
||||
Free_Class.Net()
|
||||
Ans = ADGroups
|
||||
End
|
||||
|
||||
Swap @FM With @VM In Ans
|
||||
|
||||
Return Ans
|
Reference in New Issue
Block a user