Active Directory/Connect: Difference between revisions
Schol-R-LEA (talk | contribs) m (Omitting MIPS assembly) |
No edit summary |
||
Line 19: | Line 19: | ||
$ldap = ldap_connect($hostname, $port); |
$ldap = ldap_connect($hostname, $port); |
||
$success = ldap_bind($ldap, $username, $password);</lang> |
$success = ldap_bind($ldap, $username, $password);</lang> |
||
=={{header|Python}}== |
|||
{{works with|Python|2.6}} |
|||
{{libheader|python-ldap}} |
|||
<lang python>import ldap |
|||
l = ldap.initialize("ldap://server") |
|||
try: |
|||
l.protocol_version = ldap.VERSION3 |
|||
l.set_option(ldap.OPT_REFERRALS, 0) |
|||
bind = l.simple_bind_s("me@domain.com", "password") |
|||
finally: |
|||
l.unbind() |
|||
</lang> |
|||
Output: |
|||
<pre> |
|||
(1, 2, 3) |
|||
(1, 3, 2) |
|||
(2, 1, 3) |
|||
(2, 3, 1) |
|||
(3, 1, 2) |
|||
(3, 2, 1) |
|||
</pre> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
Revision as of 09:12, 10 October 2010
You are encouraged to solve this task according to the task description, using any language you may know.
Perl
LDAP Modules <lang perl> use Net::LDAP;
my $ldap = Net::LDAP->new('ldap://ldap.example.com') or die $@; my $mesg = $ldap->bind( $bind_dn, password => $bind_pass ); </lang>
PHP
PHP LDAP Reference <lang php><?php $ldap = ldap_connect($hostname, $port); $success = ldap_bind($ldap, $username, $password);</lang>
Python
<lang python>import ldap
l = ldap.initialize("ldap://server") try:
l.protocol_version = ldap.VERSION3 l.set_option(ldap.OPT_REFERRALS, 0)
bind = l.simple_bind_s("me@domain.com", "password")
finally:
l.unbind()
</lang>
Output:
(1, 2, 3) (1, 3, 2) (2, 1, 3) (2, 3, 1) (3, 1, 2) (3, 2, 1)
Ruby
Similar to Tcl, assume the AD server talks LDAP.
There are many Ruby LDAP packages ([1]) -- this solution uses Net::LDAP ("Pure Ruby LDAP Tools" on RubyForge, gem name "ruby-net-ldap")
<lang ruby>require 'rubygems' require 'net/ldap' ldap = Net::LDAP.new(:host => 'ldap.example.com', :base => 'o=companyname') ldap.authenticate('bind_dn', 'bind_pass')</lang>
Tcl
This does not use SSPI/Kerberos yet, so your AD would need to allow simple ldap access. <lang tcl>package require ldap set conn [ldap::connect $host $port] ldap::bind $conn $user $password</lang>
VBScript
Creating the normal connection to AD <lang vbscript>Set objConn = CreateObject("ADODB.Connection") Set objCmd = CreateObject("ADODB.Command") objConn.Provider = "ADsDSOObject" objConn.Open</lang>