Skip to content

Commit 1589556

Browse files
author
Austin Ziegler
committed
Fixing some documentation formatting.
1 parent 8e9a8a4 commit 1589556

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

lib/net/ldap.rb

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ class LdapError < StandardError; end
311311

312312
DefaultHost = "127.0.0.1"
313313
DefaultPort = 389
314-
DefaultAuth = {:method => :anonymous}
314+
DefaultAuth = { :method => :anonymous }
315315
DefaultTreebase = "dc=com"
316316

317317
StartTlsOid = "1.3.6.1.4.1.1466.20037"
@@ -343,8 +343,7 @@ module LdapControls
343343
PagedResults = "1.2.840.113556.1.4.319" # Microsoft evil from RFC 2696
344344
end
345345

346-
# LDAP::result2string
347-
def self.result2string(code) # :nodoc:
346+
def self.result2string(code) #:nodoc:
348347
ResultStrings[code] || "unknown result (#{code})"
349348
end
350349

@@ -428,9 +427,14 @@ def initialize(args = {})
428427
# ldap.host = server_ip_address
429428
# psw = proc { your_psw_function }
430429
# ldap.authenticate "cn=Your Username, cn=Users, dc=example, dc=com", psw
430+
#
431431
def authenticate(username, password)
432432
password = password.call if password.respond_to?(:call)
433-
@auth = {:method => :simple, :username => username, :password => password}
433+
@auth = {
434+
:method => :simple,
435+
:username => username,
436+
:password => password
437+
}
434438
end
435439
alias_method :auth, :authenticate
436440

@@ -442,7 +446,7 @@ def authenticate(username, password)
442446
# additional capabilities are added, more configuration values will be
443447
# added here.
444448
#
445-
# Currently, the only supported argument is {:method => :simple_tls}.
449+
# Currently, the only supported argument is { :method => :simple_tls }.
446450
# (Equivalently, you may pass the symbol :simple_tls all by itself,
447451
# without enclosing it in a Hash.)
448452
#
@@ -471,7 +475,7 @@ def authenticate(username, password)
471475
def encryption(args)
472476
case args
473477
when :simple_tls, :start_tls
474-
args = {:method => args}
478+
args = { :method => args }
475479
end
476480
@encryption = args
477481
end
@@ -485,7 +489,7 @@ def encryption(args)
485489
# automatically when the block finishes.
486490
#
487491
# # (PSEUDOCODE)
488-
# auth = {:method => :simple, :username => username, :password => password}
492+
# auth = { :method => :simple, :username => username, :password => password }
489493
# Net::LDAP.open(:host => ipaddress, :port => 389, :auth => auth) do |ldap|
490494
# ldap.search(...)
491495
# ldap.add(...)
@@ -510,6 +514,11 @@ def self.open(args)
510514
# members of the object returned from #get_operation_result. Check
511515
# #get_operation_result.error_message and
512516
# #get_operation_result.matched_dn.
517+
#
518+
#--
519+
# Modified the implementation, 20Mar07. We might get a hash of LDAP
520+
# response codes instead of a simple numeric code.
521+
#++
513522
def get_operation_result
514523
os = OpenStruct.new
515524
if @result.is_a?(Hash)
@@ -536,7 +545,7 @@ def get_operation_result
536545
# the class method Net::LDAP#open.
537546
#
538547
# # (PSEUDOCODE)
539-
# auth = {:method => :simple, :username => username, :password => password}
548+
# auth = { :method => :simple, :username => username, :password => password }
540549
# ldap = Net::LDAP.new(:host => ipaddress, :port => 389, :auth => auth)
541550
# ldap.open do |ldap|
542551
# ldap.search(...)
@@ -705,7 +714,6 @@ def bind(auth = @auth)
705714
begin
706715
conn = Connection.new(:host => @host, :port => @port,
707716
:encryption => @encryption)
708-
709717
@result = conn.bind(auth)
710718
ensure
711719
conn.close if conn
@@ -753,11 +761,9 @@ def bind(auth = @auth)
753761
# ldap.port = 389
754762
# ldap.auth "cn=manager, dc=yourcompany, dc=com", "topsecret"
755763
#
756-
# result = ldap.bind_as(
757-
# :base => "dc=yourcompany, dc=com",
758-
# :filter => "(mail=#{user})",
759-
# :password => psw
760-
# )
764+
# result = ldap.bind_as(:base => "dc=yourcompany, dc=com",
765+
# :filter => "(mail=#{user})",
766+
# :password => psw)
761767
# if result
762768
# puts "Authenticated #{result.first.dn}"
763769
# else
@@ -798,7 +804,7 @@ def bind_as(args = {})
798804
# :sn => "Smith",
799805
# :mail => "gsmith@example.com"
800806
# }
801-
# Net::LDAP.open (:host => host) do |ldap|
807+
# Net::LDAP.open(:host => host) do |ldap|
802808
# ldap.add(:dn => dn, :attributes => attr)
803809
# end
804810
def add(args)
@@ -1164,8 +1170,7 @@ def setup_encryption(args)
11641170
# go here.
11651171
when :start_tls
11661172
msgid = next_msgid.to_ber
1167-
request =
1168-
[StartTlsOid.to_ber].to_ber_appsequence(Net::LdapPdu::ExtendedRequest)
1173+
request = [StartTlsOid.to_ber].to_ber_appsequence(Net::LdapPdu::ExtendedRequest)
11691174
request_pkt = [msgid, request].to_ber_sequence
11701175
@conn.write request_pkt
11711176
be = @conn.read_ber(AsnSyntax)

0 commit comments

Comments
 (0)