DESCRIPTION
Logon hours attribute - logonHours - has an OctetString syntax. It's not obvious how to deal with such attributes. This article provides a script sample on how to set logon hours attribute to a user account.
Rather than compose required logon hours in your script, it is recommended to define required logon hours for some template account, and then copy its value from the Advanced Properties dialog to the script.
Run ActiveRoles Server Snap-in, open template user account properties, go to the Account tab, click the Logon Hours button and define required logon hours. Click OK to close the Logon Hours dialog and then OK once again to close the user account property sheet. To obtain logon hours value, use the Advanced Properties dialog. Right-click the template user account, click All Tasks -> Advanced Properties. Select the "Show all possible attributes" option, select logonHours attribute and click Edit. Copy the value to the buffer. Value should look like "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" (for all hours allowed) or "0000E0FFFFFFFFFFFFFFFFFFFFFFFFFFFF1F000000" (for all hours on Monday though Friday). Paste the value to the beginning of the script, provided below. This script sets the logon hours value to a user account. Paste the logon hours value, obtained from the Advanced Properties dialog of the template account, to the c_strLogonHours constant value. The trick here is to use IEDMOctetString utility interface to transform a string value into an octet string value . For details about the IEDMOctetString interface, see ActiveRoles Server SDK
Note This code may use functions from the Active Roles Script Policy Best Practices. Please, follow the link to obtain instructions and code for those functions.
SCRIPT
'*********************************************************************************
' 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.
'*********************************************************************************
' This standalone script demonstrates how to set logon hours of a user account.
' Logon hours value can be obtained from the Advanced Properties dialog of another account.
'
' Paste logon hours value here, as a value of this constant
Const c_strLogonHours = "E0FF01E0FF01E0FF01E0FF01E0FF01E0FF01E0FF01"
set objOctetString = CreateObject("AelitaEDM.EDMOctetString")
objOctetString.Set c_strLogonHours
Set objUser = GetObject("EDMS://CN=JohnS,OU=NY,DC=domain,DC=com")
objUser.Put "logonHours", objOctetString.GetOctetString
objUser.SetInfo
WScript.Echo "OK"
'***** END OF CODE ***************************************************************