RosettaCodeData/Task/Active-Directory-Connect/NetRexx/active-directory-connect-1.netrexx
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

43 lines
1.3 KiB
Text

/* NetRexx */
options replace format comments java crossref symbols binary
import org.apache.directory.ldap.client.api.LdapConnection
import org.apache.directory.ldap.client.api.LdapNetworkConnection
import org.apache.directory.shared.ldap.model.exception.LdapException
import org.slf4j.Logger
import org.slf4j.LoggerFactory
class RDirectoryLDAP public
properties constant
log_ = LoggerFactory.getLogger(RDirectoryLDAP.class)
properties private static
connection = LdapConnection null
method main(args = String[]) public static
ldapHostName = String "localhost"
ldapPort = int 10389
if log_.isInfoEnabled() then log_.info("LDAP Connection to" ldapHostName "on port" ldapPort)
connection = LdapNetworkConnection(ldapHostName, ldapPort)
do
if log_.isTraceEnabled() then log_.trace("LDAP bind")
connection.bind()
if log_.isTraceEnabled() then log_.trace("LDAP unbind")
connection.unBind()
catch lex = LdapException
log_.error("LDAP Error", Throwable lex)
catch iox = IOException
log_.error("I/O Error", Throwable iox)
finally
do
if connection \= null then connection.close()
catch iox = IOException
log_.error("I/O Error on connection.close()", Throwable iox)
end
end
return