Using a config script is the easiest way to configure and initialize Gldapo. Config scripts are parsed using Groovy's ConfigSlurper class.
By default, Gldapo will look for a file called gldapo-conf.groovy on the classpath. To initialize Gldapo using such a file, simply call initialize() with no arguments ...
import gldapo.Gldapo Gldapo.initialize()
Alternatively, you can specify the location of the config file using a URL ...
import gldapo.Gldapo
Gldapo.initialize(new URL("file:/mygldapoconfig.groovy"))
The following is an example config script ...
directories {
directory1 {
defaultDirectory = true
url = "ldap://example.com"
base = "ou=example,dc=com"
userDn = "uid=someuser,ou=example,dc=com"
password = "password"
searchControls {
countLimit = 40
timeLimit = 600
searchScope = "subtree"
}
}
directory2 {
urls = [
"ldap://s1.example2.com",
"ldap://s2.example2.com",
]
base = "ou=example2,dc=com"
}
}
schemas = [ # An array of class objects that are the Gldap Schema Classes
my.app.MyGldapoSchemaClass1,
my.app.MyGldapoSchemaClass2
]
typemappings = [
my.app.MyTypeMappings
]
When config scripts are parsed, they are parsed into groovy.util.ConfigObjects which implement the java.util.Map interface.
The javadoc for the classes that make up the Gldapo config serve as the reference of config options. Javadoc is currently not available so I am afraid the source is the current reference. See the initialize(Map) method of the Gldapo ...
One handy feature of the Groovy Config mechanism is the ability to set different values depending on the environment.
Consider the situation where you might want to use a different LDAP server for a dev/test context and a different server for production. This is easy to achieve with config scripts ...
directories {
d1 {
url = "ldap://dev.example.com" // Use this for everthing but production
}
}
environments { // <-- 'environments' key word
production {
directories {
d1 {
url = "ldap://example.com" // Use this one for production
}
}
}
}
Any value at all in the config script can be environment sensitive.
To specify which environment to use, pass the name of the environment to initialize() ...
import gldapo.Gldapo
Gldapo.initialize("production") // Using default of gldapo-conf.groovy
// Or
Gldapo.initialze(new URL("file://mygldapoconfig.groovy"), "production") // Using a custom URL