Hello,
In one of the future releases, we'll make it possible to specify a text representation of a date when an account must expire. For now, you can workaround this by using a certain virtual attribute for specifying the expiration date in the text format. Adaxes provides a set of virtual attributes that are not stored in AD, but can be used the same as any other attribute of AD objects. You can specify the account expiration date in your CSV files using one of such attributes that allows passing text data, for example, CustomAttributeText1. Also, you can create a Business Rule triggered by creating a new account in AD that will set the expiration date of the account being created to the date specified in the virtual attribute.
If you implement a Business Rule as described below, you will be able to use any valid text that represents a date to specify account expiration date in the CSV file, for example 7/18/2015, 10.01.2016 or February 15, 2015.
To do this:
-
In the CSV file that you want to import, set the header of the column that contains account expiration dates to the LDAP name of the virtual property that you chose. For example, if you chose CustomAttributeText1, the column header must be adm-CustomAttributeText1.
-
Create a Business Rule that sets the account expiration date based on the value of the virtual attribute. To do this:
-
Create a new Business Rule.
-
On the 2nd step of the Create Business Rule wizard, select User and Before Creating a User.
-
On the 3rd step, add the Run a Program or PowerShell script action and paste the following script in the Script field:
```powershell
# Get account expiration date from the virtual property
$accountExpiresText = $Context.GetModifiedPropertyValue("adm-CustomAttributeText1")
# Clear the virtual property
$Context.SetModifiedPropertyValue("adm-CustomAttributeText1", $NULL)
# Convert the text representation of the date into the DateTime format
try
{
$accountExpires = [System.DateTime]::Parse($accountExpiresText)
}
catch
{
$Context.LogMessage("Failed to set an expiration date for the user. " + $_.Exception.Message, "Warning") # TODO: modify me
return
}
$Context.SetModifiedPropertyValue("accountExpires", $accountExpires)
```
-
Enter a short description for the script and click OK.
-
Now, you need to add a condition for the Business Rule to be triggered only when an expiration date is specified in the virtual attribute. For this purpose, double-click Always.
-
Select the If <property> <relation> <value> condition.
-
Expand the <property> drop-down list and select Show all properties.
-
Select the virtual property that you chose for passing the expiration date, for example, CustomAttributeText1.
-
Select is not empty.
-
Click OK.
-
Finish creation of the Business Rule.
-
Import the CSV file using the Import Data Wizard.