5.5.1

Table Of Contents
} finally {
myMailClient.closeFolder();
myMailClient.close();
}
File System Scripting Examples
Workflow scripted elements, actions, and policies require scripting of common file system tasks. You can
cut, paste, and adapt these examples into your scripted elements.
NOTE Access to the file system is limited by default. To access the file server from Orchestrator, see
“Accessing the Orchestrator Server File System from JavaScript and Workflows,” on page 129.
Add Content to a Simple Text File
The following JavaScript example adds content to a text file.
var tempDir = System.getTempDirectory() ;
var fileWriter = new FileWriter(tempDir + "/readme.txt") ;
fileWriter.open() ;
fileWriter.writeLine("File written at : "+new Date()) ;
fileWriter.writeLine("Another line") ;
fileWriter.close() ;
Obtain the Contents of a File
The following JavaScript example obtains the contents of a file from the Orchestrator server host machine.
var tempDir = System.getTempDirectory() ;
var fileReader = new FileReader(tempDir + "/readme.txt") ;
fileReader.open() ;
var fileContentAsString = fileReader.readAll();
fileReader.close() ;
LDAP Scripting Examples
Workflow scripted elements, actions, and policies require scripting of common LDAP tasks. You can cut,
paste, and adapt these examples into your scripted elements.
Convert LDAP Objects to Active Directory Objects
The following JavaScript example converts LDAP group elements to Active Directory user group objects,
and the reverse.
var ldapGroup ;
// convert from ldap element to Microsoft:UserGroup object
var adGroup = ActiveDirectory.search("UserGroup",ldapGroup.commonName) ;
// convert back to LdapGroup element
var ldapElement = Server.getLdapElement(adGroup.distinguishedName) ;
Chapter 2 Scripting
VMware, Inc. 135