Back to User management: Other
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 then 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 Account tab, click the Logon Hours button and define required logon hours. Click OK to close Logon Hours dialog and then OK once again to close the user account property sheet. To obtain logon hours value, use Advanced Properties dialog. Right click the template user account, click All Tasks -> Advanced Properties. Select "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 begging 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 string into octet string. For details about the IEDMOctetString interface, see ActiveRoles Server SDK
Note This code may use functions from the ARS 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 MERCHANTBILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
'
' IF YOU WANT THIS FUNCTIONALITY TO BE CONDITIONALLY SUPPORTED,
' PLEASE CONTACT QUEST PROFESSIONAL SERVICES.
'*********************************************************************************
'
' This code is published on the ActiveRoles Script Center:
' http://communities.quest.com/docs/DOC-9991
'
' This code may use functions from the ARS Script Policy Best Practices:
' http://communities.quest.com/docs/DOC-10016
'
' Please, follow the link to obtain instructions and code for those functions.
'*********************************************************************************
' Script name: Set logon hours
' Version: 1.0.0
'
' 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 ***************************************************************
COMPATIBILITY
Script compatible with the following version(s): <Not specified>