Active Directory/Connect: Difference between revisions

Content added Content deleted
mNo edit summary
(formatting)
Line 116: Line 116:


=={{header|Kotlin}}==
=={{header|Kotlin}}==
<lang scala>package directory
<lang scala>
import org.apache.directory.api.ldap.model.exception.LdapException

import org.apache.directory.ldap.client.api.LdapNetworkConnection
import kotlin.properties.get

import java.io.IOException
import java.io.IOException
import java.util.logging.Level
import java.util.logging.Level
import java.util.logging.Logger
import java.util.logging.Logger


class LDAP(map: Map<String, String>) {
import org.apache.directory.api.ldap.model.exception.LdapException
import org.apache.directory.ldap.client.api.LdapNetworkConnection

class LDAP(val map: Map<String, String>) {
fun run() {
fun run() {
var connection: LdapNetworkConnection? = null
var connection: LdapNetworkConnection? = null
try {
try {
if (info)
if (info) log.info("LDAP Connection to $hostname on port $port")
log.info("LDAP Connection to $hostname on port $port")
connection = LdapNetworkConnection(hostname, port.toInt())
connection = LdapNetworkConnection(hostname, port.toInt())


try {
try {
if (info)
if (info) log.info("LDAP bind")
log.info("LDAP bind")
connection.bind()
connection.bind()
} catch (e: LdapException) {
} catch (e: LdapException) {
Line 144: Line 138:


try {
try {
if (info)
if (info) log.info("LDAP unbind")
log.info("LDAP unbind")
connection.unBind()
connection.unBind()
} catch (e: LdapException) {
} catch (e: LdapException) {
Line 152: Line 145:
} finally {
} finally {
try {
try {
if (info)
if (info) log.info("LDAP close connection")
log.info("LDAP close connection")
connection!!.close()
connection!!.close()
} catch (e: IOException) {
} catch (e: IOException) {
Line 167: Line 159:
}
}


fun main(args: Array<String>) = LDAP(mapOf("hostname" to "localhost", "port" to "10389")).run()</lang>
fun main(args: Array<String>) = LDAP(mapOf("hostname" to "localhost", "port" to "10389")).run()
</lang>


=={{header|NetRexx}}==
=={{header|NetRexx}}==