Skip to content

ReportCustomColumnScriptContext

The ReportCustomColumnScriptContext class provides methods and properties for PowerShell scripts used to generate report custom columns. To access an instance of this class, use a predefined PowerShell variable called $Context.

Inheritance: The ReportCustomColumnScriptContext class inherits from the Object class.

Methods

Properties

  • Property

  • Description

  • ColumnId

  • Gets the unique identifier of the custom column.

  • ColumnDisplayName

  • Gets the display name of the custom column.

  • Value

  • Gets or sets the custom column value.

  • ValueType

  • Gets the data type of the custom column.

  • ReportItem

  • Gets the report item for which the custom column value is generated.

  • ReportArguments

  • Gets arguments for report generation.

  • Initiator

  • Gets an instance of the ExecuteScriptInitiatorInfo class that allows you to get information about the user for which the report is generated.

  • RunAs

  • Gets an instance of the NetworkCredential class that represents the credentials of the user account under which the script used to generate the custom column is executed.

  • ItemID

  • Gets or sets the identifier of the report item for which the custom column value is generated.

Details

GetADObject()

Returns the Active Directory object for which the custom column value is generated.

IAdmTop GetADObject()

Examples

The following code sample sets the custom column value to the Full Name of the object’s manager.

# Get AD object
$obj = $Context.GetADObject()

# Get manager of the object
$managerDN = $obj.Get("manager")
$manager = $Context.BindToObjectByDN($managerDN)

# Set column value
$Context.Value = $manager.Get("cn")

GetParameterValue(String)

Returns the value of the given report parameter.

String GetParameterValue(String paramName)

GetParameterValue(String, Boolean)

Returns the value of the given report parameter. The method allows you to specify whether to convert the parameter value into a format required for LDAP filters.

String GetParameterValue(String paramName, Boolean valueForLdapFilter)

Parameters

  • paramName - Specifies the name of the report parameter.
  • valueForLdapFilter - If set to TRUE, the method escapes necessary characters in the parameter value (e.g. for “John the method will return “John\2A”) or converts a date into the format required for LDAP filters (e.g. “20180122151647.0Z”*).

IsProtectedFromDeletion()

Returns a value indicating whether the object with the given security descriptor is protected from accidental deletion.

void ConvertToRegularMailbox()

Parameters

  • securityDescriptor - Specifies the security descriptor of the object. The security descriptor must contain the discretionary access-control list (DACL) part. The DACL part is included by default when you get the ntSecurityDescriptor property of an object.
  • parentSecurityDescriptor - Specifies the security descriptor of the object parent. The security descriptor must contain the discretionary access-control list (DACL) part. The DACL part is included by default when you get the ntSecurityDescriptor property of an object.

Examples

The following code sample sets the custom column value to “Protected” if an object is protected from accidental deletion.

# Get AD object
$obj = $Context.GetADObject()

# Get object security descriptor
$objSecurityDescriptor = $obj.Get("ntSecurityDescriptor")

# Get security descriptor of the object parent
$parent = $Context.BindToObject($obj.Parent)
$parentSecurityDescriptor = $parent.Get("ntSecurityDescriptor")

# Set column value
if ($Context.IsProtectedFromDeletion($objSecurityDescriptor, $parentSecurityDescriptor))
{
    $Context.Value = "Protected"
}

GetHostNameFromNetworkPath()

Returns the host name from the given network path.

String GetHostNameFromNetworkPath(String networkPath)

Examples

The following code sample sets the custom column value to the host name of the user’s home directory.

# Get AD object
$user = $Context.GetADObject()

# Get host name from the home directory
$homeDirectory = $user.Get("homeDirectory")

# Set column value
$Context.Value = $Context.GetHostNameFromNetworkPath($homeDirectory)

CreatePropertyValueComparer()

Returns an instance of the IEqualityComparer interface that can be used to compare values of the given property.

IEqualityComparer CreatePropertyValueComparer(String propertyName)

GetPropertyValueDisplayText()

Returns the value of the given directory object property in a human-readable format.

String GetPropertyValueDisplayText(String propertyName, Object value)

Parameters

  • propertyName - Specifies the name of the directory object property.
  • value - Specifies the property value.

Examples

The following code sample adds information about account expiration to the custom column.

# Get AD object
$user = $Context.GetADObject()

# Get display text for the Account Expires property
$accountExpires = $user.Get("accountExpires")
$accountExpiresDisplayText = $Context.GetPropertyValueDisplayText("accountExpires", $accountExpires)

# Set column value
$Context.Value = "Account expiration date: $accountExpiresDisplayText"

LogMessage()

Adds a message of the given type to the report Data Retrieval Log.

void LogMessage(String message, ExecuteScriptLogMessageType messageType)

Parameters

  • message - Specifies the message text.
  • messageType - Specifies the message type.

Examples

The following code sample adds messages of different types to the report Data Retrieval Log.

$Context.LogMessage("My Message", "Information")
$Context.LogMessage("My Warning", "Warning")
$Context.LogMessage("My Error Message", "Error")

LogException()

Adds the given exception to the report Data Retrieval Log.

void LogException(Exception exception)

Remarks

The method is supported starting with Adaxes version 2019.1 Update 3.

Examples

try
{
    ...
}
catch
{
    $Context.LogException($_.Exception)
}

BindToObject()

Binds to a directory object by the given ADS path.

IAdmTop BindToObject(String adsPath)

Parameters

The adsPath parameter specifies the ADS path of the directory object to bind to.


BindToObjectEx()

Binds to a directory object by the given ADS path. This method extends the BindToObject method with the ability to specify whether to perform all actions on the object directly or pass it through Adaxes pipeline. When passed through the pipeline, Adaxes functionality is applied (e.g. Security Roles).

IAdmTop BindToObjectEx(String adsPath, Boolean pipelined)

Parameters

  • adsPath - Specifies the ADS path of the directory object to bind to.
  • pipelined - Set to FALSE to perform all actions on the object directly. Set to TRUE to apply Adaxes functionality.

BindToObjectByDN()

Binds to a directory object by the given distinguished name (DN).

IAdmTop BindToObjectByDN(String dn)

Parameters

The dn parameter specifies the distinguished name (DN) of the directory object to bind to.


BindToObjectByDNEx()

Binds to a directory object by the given distinguished name (DN). This method extends the BindToObjectByDN method with the ability to specify whether to perform all actions on the object directly or pass it through Adaxes pipeline. When passed through the pipeline, Adaxes functionality is applied (e.g. Security Roles).

IAdmTop BindToObjectByDNEx(String dn, Boolean pipelined)

Parameters

  • dn - Specifies the distinguished name (DN) of the directory object to bind to.
  • pipelined - Set to FALSE to perform all actions on the object directly. Set to TRUE to apply Adaxes functionality.

BindToObjectBySearchResult()

Binds to a directory object by the specified search result.

IAdmTop BindToObjectBySearchResult(IAdmSearchResult searchResult)

Parameters

The searchResult parameter specifies the search result entry that contains properties for binding to the object.

Remarks

To make binding less resource-intensive, it is recommended for the search result to contain the objectGuid and objectClass properties.


BindToObjectBySearchResultEx()

Binds to a directory object by the specified search result. This method extends the BindToObjectBySearchResult method with the ability to specify whether to perform all actions on the object directly or pass it through Adaxes pipeline. When passed through the pipeline, Adaxes functionality is applied (e.g. Security Roles).

IAdmTop BindToObjectBySearchResultEx(IAdmSearchResult searchResult, Boolean pipelined)

Parameters

  • searchResult - Specifies the search result entry that contains properties for binding to the object.
  • pipelined - Set to FALSE to perform all actions on the object directly. Set to TRUE to apply Adaxes functionality.

Remarks

To make binding less resource-intensive, it is recommended for the search result to contain the objectGuid and objectClass properties.


SendMail()

Sends an email to the specified recipient.

void SendMail(String toAddress, 
              String subject, 
              String textBody, 
              String htmlBody)

Parameters

  • toAddress - Specifies the recipient’s e-mail address.
  • subject - Specifies the subject of the email.
  • textBody - Specifies the body of the email in the plain text format. This parameter can be set to NULL.
  • htmlBody - Specifies the body of the email in the HTML format. This parameter can be set to NULL.

SendSms(String, String)

Sends an SMS to the specified phone number.

void SendSms(String mobileNumber, String smsText)

Parameters

  • mobileNumber - Specifies the phone number of the recipient.
  • smsText - Specifies the text of the SMS message to send.

SendSms(String, String, IAdmTop)

Sends an SMS message with the given text to the given phone number. This method allows you to specify the object used to resolve value references in the SMS settings.

void SendSms(String mobileNumber, 
             String smsText, 
             IAdmTop objectToResolveValueReferences)

Parameters

  • mobileNumber - Specifies the phone number of the recipient.
  • smsText - Specifies the text of the SMS message to send.
  • objectToResolveValueReferences - Specifies the object used to resolve value references in the SMS settings.

GetObjectDomain()

Extracts the domain name from the passed distinguished name (DN).

String GetObjectDomain(String objectDN)

Parameters

The objectDN parameter specifies the distinguished name from which to extract the domain name.


GetDisplayNameFromAdsPath()

Builds a display name of a directory object from its ADS path.

String GetDisplayNameFromAdsPath(String adsPath)

Parameters

The adsPath parameter specifies the ADS path of the directory object to build a display name for.


GetWellKnownContainerPath()

Returns the ADS path of a well-known container for Adaxes configuration objects. For a list of container aliases, see Aliases for containers that store Adaxes configuration objects.

String GetWellKnownContainerPath(String containerAlias)

Parameters

The containerAlias parameter specifies the alias of the well-known container.


GetDomainController()

Returns the DNS host name of the domain controller the Adaxes service is currently connected to.

String GetDomainController(String domain)

Parameters

The domain parameter specifies the domain for which to return the domain controller. You can use the fully qualified domain name (e.g. mydomain.com) or NETBIOS domain name (e.g. MYDOMAIN) in the parameter.

Remarks

The method is supported starting with Adaxes version 2019.1.


FetchAllPropertyValues()

Returns all values of the given property for the given directory object. The method overcomes the limit of maximum property values returned per request.

public Object[] FetchAllPropertyValues(IAdmTop obj, String propertyName)

Parameters

  • obj - Specifies the directory object.
  • propertyName - Specifies the name of the directory object property.

Examples

The following code sample sets the custom column value to the number of user’s subordinates.

# Get AD object
$user = $Context.GetADObject()

# Get DNs of user's subordinates
$subordinateDNs = $Context.FetchAllPropertyValues($user, "directReports")

# Set column value
$Context.Value = $subordinateDNs.Length

GetOffice365Credential()

Returns credentials of the Microsoft 365 tenant associated with the given AD object.

PSCredential GetOffice365Credential(IAdmTop obj)

Return value

The method returns an instance of the PSCredential class. If there is no tenant associated with the object, the method returns NULL.


IsApprovalRequiredException()

Returns TRUE if the given exception occurred because the operation requires approval.

Boolean IsApprovalRequiredException(Exception exception)

Remarks

The method is supported starting with Adaxes version 2019.1 Update 3.

Examples

try
{
    ...
}

catch
{
    if ($Context.IsApprovalRequiredException($_.Exception))
    {
        $Context.LogException($_.Exception)
    }
    else
    {
        throw
    }    
}

CreateGuidBasedSearcher()

Creates an instance of a directory searcher configured to search for objects with the given GUIDs. Each GUID must be represented as an array of 16 bytes (Byte[]).

public DirectorySearcher CreateGuidBasedSearcher(IList<Object> objectGuids)

Parameters

The objectGuids parameter specifies a list of object GUIDs.


ColumnId

Gets the unique identifier of the custom column.

  • Type:
  • String
  • Access:
  • Read-only

ColumnDisplayName

Gets the display name of the custom column.

  • Type:
  • String
  • Access:
  • Read-only

Value

Gets or sets the custom column value.

  • Type:
  • Object
  • Access:
  • Read/Write

ValueType

Gets the data type of the custom column.


ReportItem

Gets the report item for which the custom column value is generated.


ReportArguments

Gets arguments for report generation.


Initiator

Gets an instance of the ExecuteScriptInitiatorInfo class that allows you to get information about the user for which the report is generated.


RunAs

Gets an instance of the NetworkCredential class that represents the credentials of the user account under which the script used to generate the custom column is executed. If the property is NULL, the credentials of the Adaxes service account are used.

  • Type:
  • NetworkCredential
  • Access:
  • Read-only

ItemID

Gets or sets the identifier of the report item for which the custom column value is generated.

  • Type:
  • Int32
  • Access:
  • Read/Write

Requirements

Minimum required version: 2018.1

See also