IModifyActionToApprove
The IModifyActionToApprove interface allows modifying property values in certain operations that are pending approval.
Inheritance: IUnknown
Methods
-
Method
-
Description
-
CanModifyProperty()
-
Checks whether a specific property can be modified.
-
ModifyAction()
-
Modifies the values of the specified property entries in the pending operation.
Details
CanModifyProperty()
Checks whether a specific property can be modified.
bool CanModifyProperty(string name, int? mask = null)
Parameters
- name – Specifies the name of the property to check.
- mask – An optional parameter that specifies a bitmask for checking specific bits of integer properties.
Remarks
You can only modify the pending values of properties already included in the initial operation.
If this method returns true, it does not necessarily mean that a particular property can be modified in a particular request. It only means that the user account bound to the request has sufficient permissions to modify the property value.
ModifyAction()
Modifies the values of the specified property entries in the pending operation.
void ModifyAction(IAdmPropertyList modifications)
Parameters
- modifications – Specifies a list of property entries to modify. If the property list contains property entries not initially included in the pending operation, the method will throw an exception.
Remarks
If you amend the values only in some property entries but pass the entire property list to this method, every property included in the initial operation will appear as updated in the log. This may not be accurate.
We recommended clearing the property list with PurgePropertyList and adding back only the property entries you want to modify.
Examples
The following code sample modifies all pending approval requests where the Office property is being updated. It replaces the pending value with Chicago office (New).
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") # Connect to the Adaxes service. $ns = New-Object("Softerra.Adaxes.Adsi.AdmNamespace") $service = $ns.GetServiceDirectly("localhost") # Bind to the approval requests container. $containerPath = $service.Backend.GetConfigurationContainerPath("ApprovalRequests") $container = $service.OpenObject($containerPath.ToString(), $null, $null, 0) # Get all pending approval requests. $requests = $container.GetApprovalRequests("ADM_APPROVALSTATE_PENDING") # Iterate through the requests. foreach ($requestID in $requests) { # Bind to the approval request. $guid = [Guid]$requestID $request = $service.OpenObject("Adaxes://<GUID=$guid>", $null, $null, 0) $operation = $request.ActionToApprove if (-not $operation.IsOperationOfType($null, "set properties")) { # Not an Update operation. continue } # Get the property item. $propertyList = $operation.PropertyList try { $propertyList.GetPropertyItem("physicalDeliveryOfficeName", "ADSTYPE_CASE_IGNORE_STRING") } catch { # Property was not modified in the request. continue } # Create property entry with the new value. $value = New-Object "Softerra.Adaxes.Adsi.AdsPropertyValue" $value.PutObjectProperty("ADSTYPE_UNKNOWN", "Chicago office (New)") $propertyEntry = New-Object "Softerra.Adaxes.Adsi.AdsPropertyEntry" -Property @{ Name = "physicalDeliveryOfficeName"; ADsType = "ADSTYPE_CASE_IGNORE_STRING"; ControlCode = "ADS_PROPERTY_UPDATE" Values = @([Softerra.Adaxes.Interop.Adsi.Cache.IADsPropertyValue]$value) } # Save changes. $propertyList.PurgePropertyList() $propertyList.PutPropertyItem($propertyEntry) $request.ModifyAction($propertyList) $request.SetInfo() }
- C#
-
using System; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.ApprovalRequests; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { // Connect to the Adaxes service. AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Bind to the approval requests container. string containerPath = service.Backend.GetConfigurationContainerPath("ApprovalRequests"); IAdmApprovalRequestContainer container = (IAdmApprovalRequestContainer)service.OpenObject( containerPath, null, null, 0); // Get all pending approval requests. object[] requests = (object[])container.GetApprovalRequests( ADM_APPROVALSTATE_ENUM.ADM_APPROVALSTATE_PENDING); // Iterate through the requests. foreach (Byte[] requestId in requests) { // Bind to the approval request. string guid = new Guid(requestId).ToString("B"); string requestPath = $"Adaxes://<GUID={guid}>"; IAdmApprovalRequest4 request = (IAdmApprovalRequest4)service.OpenObject( requestPath, null, null, 0); IAdmAction operation = request.ActionToApprove; if (!operation.IsOperationOfType(null, "set properties")) { // Not an Update operation. continue; } // Get the property item. IAdmSetPropertiesAction updateOperation = (IAdmSetPropertiesAction)operation; IADsPropertyList propertyList = updateOperation.PropertyList; try { propertyList.GetPropertyItem( "physicalDeliveryOfficeName", ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING); } catch { // Property was not modified in the request. continue; } // Create a property entry with the new value. AdsPropertyValue value = new AdsPropertyValue(); value.PutObjectProperty(ADSTYPEENUM.ADSTYPE_UNKNOWN, "Chicago Office (New)"); AdsPropertyEntry propertyEntry = new AdsPropertyEntry { Name = "physicalDeliveryOfficeName", ADsType = ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING, ControlCode = ADS_PROPERTY_OPERATION_ENUM.ADS_PROPERTY_UPDATE, Values = new object[] { value } }; // Save changes. propertyList.PurgePropertyList(); propertyList.PutPropertyItem(propertyEntry); ((IModifyActionToApprove)request).ModifyAction((IAdmPropertyList)propertyList); request.SetInfo(); } } }
For more examples on updating approval requests, see Managing approval requests.
Requirements
Minimum required version: 2025.1