DESCRIPTION
Sometimes, it is very important to know which Active Roles client is initiating a specific operation. The Active Roles SDK describes several methods to get information about request source, but none of these methods gives full information. The following script in SCRIPT ONE section demonstrates how to get full information about the request source.
Note: The GetRequestSource() function returns a valid value in script policy "pre"-handlers only such as onPreCreate, onPreModify, etc... To know a request source in "post"-handlers, you should first save the source in "pre"-handler in some Request's control as it is shown in SCRIPT TWO section.
SCRIPT ONE
'*********************************************************************************
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
'
' IF YOU WANT THIS FUNCTIONALITY TO BE CONDITIONALLY SUPPORTED,
' PLEASE CONTACT ONE IDENTITY PROFESSIONAL SERVICES.
'*********************************************************************************
Option Explicit
'*******************************************************************
' Get Request Source
'
' This function determines request source
' Possible return values:
' "AD DirSync" - request came from Active Directory by DirSync
' "DB Replication" – request came from SQL database by replication
' "Active Roles Internal" – request made by Active Roles Administrative Service
' "Quick Connect" – request made by Active Roles Quick Connect, only Quick Connect 3.x is supported
' "MMC Interface" - request made by Active Roles MMC Console
' "Web Interface" - request made by Active Roles Web Interface
' "ADSI Provider" - request made by external script or application that works with Active Roles through Active Roles ADSI provider
' something else - undetermined request source
'*******************************************************************
Function GetRequestSource(Request)
Dim SelfRequest, RequestSource, QuickConnectGuid, ClientVersion
GetRequestSource = Empty
On Error Resume Next
SelfRequest = CBool(Request.Parameter("SelfRequest"))
On Error Goto 0
If (SelfRequest = True) Then '-- request made by Active Roles Administrative Service
GetRequestSource = "Active Roles Internal"
Else
On Error Resume Next
RequestSource= Request.Parameter("RequestSource")
On Error Goto 0
If (RequestSource = 1) Then '-- request made from client
On Error Resume Next
QuickConnectGuid = Request.GetInControl("QC_ApplicationGuid")
On Error Goto 0
If (Not IsEmpty(QuickConnectGuid)) Then '-- request made by Quick Connect
GetRequestSource = "Quick Connect"
Else '-- request made by one of Active Roles Client
On Error Resume Next
ClientVersion = CStr(Security.Sessions.Current.ClientVersion) '-- get Active Roles client name and version
ClientVersion = Left(ClientVersion,13) '-- ignore version digits
On Error Goto 0
GetRequestSource = ClientVersion
End If
ElseIf (RequestSource = 2) Then '-- request came from Active Directory by DirSync
GetRequestSource = "AD DirSync"
ElseIf (RequestSource = 3) Then '-- request came from SQL database by replication
GetRequestSource = "DB Replication"
End If
End If
End Function ' GetRequestSource
'*******************************************************************
' EVENT HANDLERS
'*******************************************************************
Sub onPreModify(Request)
Dim Source
Source = GetRequestSource(Request) '-- get request source
If ((Source = "Quick Connect") Or (Source = "Web Interface")) Then
Call Err.Raise (1, "Don't use Active Roles Quick Connect and Active Roles Web Interface for this operation!")
End If
End Sub ' onPreModify
'*** END OF CODE ****************************************************
SCRIPT TWO
'*********************************************************************************
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
'
' IF YOU WANT THIS FUNCTIONALITY TO BE CONDITIONALLY SUPPORTED,
' PLEASE CONTACT ONE IDENTITY PROFESSIONAL SERVICES.
'*********************************************************************************
' EVENT HANDLERS
'*******************************************************************
Sun onPreModify(Request)
Dim Source
. . .
Source = GetRequestSource(Request)
Request.PutInControl("some-control-name", Source)
. . .
End Sub
Sun onPostModify(Request)
Dim Source
. . .
Source = Request.GetInControl("some-control-name")
. . .
End Sub
'*** END OF CODE ****************************************************