Active Directory/Connect: Difference between revisions
m
syntax highlighting fixup automation
(→{{header|Wren}}: Sigh, more errors.) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 6:
{{works with|AutoHotkey_L}}
{{trans|VBScript}}
<
objCmd := CreateObject("ADODB.Command")
objConn.Provider := "ADsDSOObject"
objConn.Open()</
=={{header|AutoIt}}==
{{works with|AutoIt}}
<
_AD_Open()</
=={{header|C}}==
With OpenLDAP:
<
...
char *name, *password;
Line 25:
ldap_simple_bind_s(ld, name, password);
... after done with it...
ldap_unbind(ld);</
=={{header|C sharp|C#}}==
<
// Requires adding a reference to System.DirectoryServices
var objDE = new System.DirectoryServices.DirectoryEntry("LDAP://DC=onecity,DC=corp,DC=fabrikam,DC=com");
</syntaxhighlight>
=={{header|ColdFusion}}==
<
<cfldap
server = "#someip#"
Line 45:
attributes = "#attributeslist#"
>
</syntaxhighlight>
=={{header|D}}==
Based on dopenldap.
<syntaxhighlight lang=d>
import openldap;
import std.stdio;
Line 68:
}
</syntaxhighlight>
=={{header|Erlang}}==
This needs a test case. Is there a LDAP server available?
<
-module(ldap_example).
-export( [main/1] ).
Line 80:
ok = eldap:simple_bind( Handle, DN, Password ),
eldap:close( Handle ).
</syntaxhighlight>
=={{header|F_Sharp|F#}}==
{{trans|C_sharp}}
<p>For Active Directory we use the library System.DirectoryServices</p>
<
<p>For your average LDAP server we use System.DirectoryServices.Protocol</p>
<p>For a minimal example we make an anonymous connect to the local machine on the well-known LDAP port 389
<
let connect = new System.DirectoryServices.Protocols.LdapConnection(ldapServer)
connect.Bind()</
=={{header|Go}}==
Line 96:
<br>
There are a large number of third-party LDAP libraries for Go. This uses one of the simpler ones and the code below is largely taken from the example on its main page.
<
import (
Line 121:
}
// Do something
}</
=={{header|Haskell}}==
Line 127:
Example uses the [https://hackage.haskell.org/package/ldap-client <tt>ldap-client</tt>] package:
<
module Main (main) where
Line 141:
Ldap.search ldap (Ldap.Dn "o=example.com") (Ldap.typesOnly True) (Attr "uid" := Text.encodeUtf8 "user") []
for_ entries $ \entry ->
print entry</
=={{header|Java}}==
Line 147:
This code uses the Apache Directory third-party library.
<
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.ldap.client.api.LdapConnection;
Line 160:
}
}
}</
=={{header|Julia}}==
<
conn = LDAPClient.LDAPConnection("ldap://localhost:10389")
LDAPClient.simple_bind(conn, "user", "password")
LDAPClient.unbind(conn)
</syntaxhighlight>
=={{header|Kotlin}}==
<
import org.apache.directory.api.ldap.model.exception.LdapException
import org.apache.directory.ldap.client.api.LdapNetworkConnection
Line 216:
fun main(args: Array<String>) = LDAP(mapOf("hostname" to "localhost", "port" to "10389")).run()
</syntaxhighlight>
=={{header|NetRexx}}==
Uses the [http://directory.apache.org/api/ Apache LDAP API], connecting to a local [http://directory.apache.org/apacheds/1.5/ ApacheDS] LDAP directory server.
<
options replace format comments java crossref symbols binary
Line 263:
return
</syntaxhighlight>
'''Sample <tt>log4j.xml</tt> configuration file:'''
<
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
Line 292:
</root>
</log4j:configuration>
</syntaxhighlight>
'''Output:'''
Line 301:
=={{header|Perl}}==
[http://search.cpan.org/dist/perl-ldap/|Perl LDAP Modules]
<
use Net::LDAP;
my $ldap = Net::LDAP->new('ldap://ldap.example.com') or die $@;
my $mesg = $ldap->bind( $bind_dn, password => $bind_pass );
</syntaxhighlight>
=={{header|Phix}}==
Line 313:
This has been tested against a random 7-year-old list of public ldap servers, getting mixed errors of
LDAP_SERVER_DOWN/LDAP_INVALID_CREDENTIALS/LDAP_INVALID_DN_SYNTAX/LDAP_CONFIDENTIALITY_REQUIRED.
<!--<
<span style="color: #008080;">include</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">/</span><span style="color: #000000;">ldap</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
Line 329:
<span style="color: #000000;">ldap_unbind</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ld</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--</
{{out}}
<pre>
Line 337:
=={{header|PHP}}==
[http://php.net/ldap PHP LDAP Reference]
<
$ldap = ldap_connect($hostname, $port);
$success = ldap_bind($ldap, $username, $password);</
=={{header|PicoLisp}}==
<
(quit "Can't open LDAP") )
(native "libldap.so" "ldap_simple_bind_s" 'I Ldap "user" "password")</
=={{header|Python}}==
Line 353:
[http://www.python-ldap.org/doc/html/index.html python-ldap Documentation]
<
l = ldap.initialize("ldap://ldap.example.com")
Line 363:
finally:
l.unbind()
</syntaxhighlight>
=={{header|Racket}}==
This version uses the ldap package, and was tested against OpenLDAP (with real values):
<
(require net/ldap)
(ldap-authenticate "ldap.somewhere.com" 389 "uid=username,ou=people,dc=somewhere,dc=com" password)</
{{trans|C}}
Line 375:
This is a direct translation of the C code -- I have no idea how to try it out since I don't have a working ldap server... So take it as a stub that waits for someone who can try it to do so. (And it's a low level thing anyway, there's an ldap package for Racket which I can't try for a similar reason.)
<
(require ffi/unsafe ffi/unsafe/define)
Line 390:
(ldap_simple_bind_s ld name password)
(ldap_unbind ld)</
=={{header|Raku}}==
Line 397:
Using module LMDB - bindings to the openLDAP library. Requires an LDAP instance.
<
my %DB := LMDB::DB.open(:path<some-dir>, %connection-parameters);
</syntaxhighlight>
%DB may be accessed, read from and written to like a native hash.
Line 410:
{{libheader|RubyGems}}
<
require 'net/ldap'
ldap = Net::LDAP.new(:host => 'ldap.example.com', :base => 'o=companyname')
ldap.authenticate('bind_dn', 'bind_pass')</
=={{header|Run BASIC}}==
{{incorrect|Run BASIC|Active Directory has nothing to do with the local file system}}
<
=={{header|Rust}}==
This solution uses the popular [https://crates.io/crates/ldap3 ldap3] crate.
<
let conn = ldap3::LdapConn::new("ldap://ldap.example.com")?;
conn.simple_bind("bind_dn", "bind_pass")?.success()?;
</syntaxhighlight>
=={{header|Scala}}==
<
import org.apache.directory.api.ldap.model.exception.LdapException
Line 444:
}
}
}</
=={{header|smart BASIC}}==
Line 450:
smart BASIC uses three separate commands to list the current directory, folder and files respectively.
<
PRINT
PRINT "Folders:"
Line 464:
FOR n = 0 TO c-1
PRINT ,a$(n)
NEXT n</
=={{header|Tcl}}==
This does not use SSPI/Kerberos yet, so your AD would need to allow simple ldap access.
<
set conn [ldap::connect $host $port]
ldap::bind $conn $user $password</
=={{header|VBScript}}==
Creating the normal connection to AD
<
Set objCmd = CreateObject("ADODB.Command")
objConn.Provider = "ADsDSOObject"
objConn.Open</
=={{header|Wren}}==
Line 483:
{{libheader|OpenLDAP}}
As it's not currently possible for Wren-cli to access OpenLDAP directly, we embed a Wren script in a C application to complete this task.
<
foreign class LDAP {
Line 514:
// do something here
ld.unbind()</
<br>
We now embed this in the following C program, compile and run it.
<
#include <stdio_ext.h>
#include <stdlib.h>
Line 635:
free(script);
return 0;
}</
{{omit from|Active Directory}}
|