Active Directory/Connect: Difference between revisions

Content deleted Content added
No edit summary
Add NetRexx implementation
Line 20: Line 20:
... after done with it...
... after done with it...
ldap_unbind(ld);</lang>
ldap_unbind(ld);</lang>

=={{header|NetRexx}}==
Uses the [http://directory.apache.org/api/| Apache LDAP API].
<lang NetRexx>/* 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
</lang>


=={{header|Perl}}==
=={{header|Perl}}==