Active Directory/Connect: Difference between revisions

From Rosetta Code
Content added Content deleted
m (→‎{{header|Tcl}}: better formatting)
(add Ruby)
Line 2: Line 2:
[[Category:Less_Than_5_Examples]]
[[Category:Less_Than_5_Examples]]


=={{header|VBScript}}==
=={{header|Ruby}}==
Similar to Tcl, assume the AD server talks LDAP.
Creating the normal connection to AD

Set objConn = CreateObject("ADODB.Connection")
There are many Ruby LDAP packages ([http://rubyforge.org/search/?type_of_search=soft&words=ldap&Search=Search]) -- this solution uses [http://net-ldap.rubyforge.org/rdoc/ Net::LDAP] ("Pure Ruby LDAP Tools" on RubyForge, gem name "ruby-net-ldap")
Set objCmd = CreateObject("ADODB.Command")

objConn.Provider = "ADsDSOObject"
{{libheader|RubyGems}}
objConn.Open
<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>


=={{header|Tcl}}==
=={{header|Tcl}}==
Line 14: Line 18:
set conn [ldap::connect $host $port]
set conn [ldap::connect $host $port]
ldap::bind $conn $user $password</lang>
ldap::bind $conn $user $password</lang>

=={{header|VBScript}}==
Creating the normal connection to AD
Set objConn = CreateObject("ADODB.Connection")
Set objCmd = CreateObject("ADODB.Command")
objConn.Provider = "ADsDSOObject"
objConn.Open


[[Category:Active Directory]]
[[Category:Active Directory]]

Revision as of 19:14, 29 July 2009

Task
Active Directory/Connect
You are encouraged to solve this task according to the task description, using any language you may know.

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")

Library: RubyGems

<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

Set objConn = CreateObject("ADODB.Connection")
Set objCmd = CreateObject("ADODB.Command")
objConn.Provider = "ADsDSOObject"
objConn.Open