自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Ruby連接到LDAP技巧分享

開(kāi)發(fā) 開(kāi)發(fā)工具
Ruby連接到LDAP實(shí)在實(shí)際編程中經(jīng)常遇到的問(wèn)題。我們會(huì)為大家詳細(xì)介紹有關(guān)Ruby連接到LDAP的相關(guān)問(wèn)題。希望對(duì)大家有所幫助。

我們?cè)趯?shí)際編寫Ruby語(yǔ)言代碼時(shí),在實(shí)現(xiàn)Ruby連接到LDAP的情況下,通常都可以使用到三種方法。在這里我們將會(huì)學(xué)到其中的兩種。#t#

Ruby連接到LDAP代碼示例:

 

  1. conn = LDAP::Conn.new("rsads02.foo.com")   
  2. conn.bind("CN=username,CN=Users,DC=foo,
    DC=com","password") do |bound|   
  3. bound.search("DC=foo,DC=com", 
    LDAP::LDAP_SCOPE_SUBTREE,"
    (&(name=*) 
    (
    objectCategory=person))", 
    ['name','ipPhone']) do |user|   
  4. puts "#{user['name']} #{user['ipPhone']}"   
  5. end   
  6. end  
  7. require 'net/ldap'   
  8. ldap = Net::LDAP.new :host => 
    server_ip_address,   
  9. :port => 389,   
  10. :auth => {   
  11. :method => :simple,   
  12. :username =>"cn=manager,dc=example,dc=com",   
  13. :password => "opensesame"   
  14.  }   
  15. filter = Net::LDAP::Filter.eq( 
    "cn", "George*" )   
  16. treebase = "dc=example,dc=com"   
  17. ldap.search( :base => treebase,
     :filter =
    > filter )do |entry|   
  18. puts "DN: #{entry.dn}"   
  19. entry.each do |attribute, values|   
  20. puts "  #{attribute}:"   
  21. values.each do |value|   
  22. puts "   --->#{value}"   
  23. end   
  24. end   
  25. end   
  26. p ldap.get_operation_result 

希望以上介紹的這些Ruby連接到LDAP的方法能夠幫助大家。

責(zé)任編輯:曹凱 來(lái)源: ddvip.com
相關(guān)推薦

2009-12-15 18:24:02

Ruby連接到orac

2009-12-15 10:23:23

Ruby應(yīng)用技巧

2009-12-18 10:47:16

Ruby裝飾模式

2009-12-16 10:10:16

Ruby打開(kāi)關(guān)閉文件

2009-12-18 14:10:29

Ruby訪問(wèn)剪貼板

2009-12-16 11:04:51

Ruby操作文件權(quán)限

2009-12-17 10:18:17

Ruby創(chuàng)建構(gòu)造器

2009-12-16 15:46:41

Ruby on rai

2009-12-16 10:49:42

Ruby操作二進(jìn)制文件

2009-12-15 18:03:46

Ruby連接數(shù)據(jù)庫(kù)

2009-12-14 09:33:04

Ruby安裝

2009-12-18 17:01:37

Ruby基礎(chǔ)代碼

2009-12-14 18:23:38

Ruby DSL測(cè)試

2009-12-14 15:30:43

安裝Ruby on R

2009-12-16 16:37:59

Ruby on Rai

2009-12-16 15:23:33

Ruby on rai

2009-12-17 17:37:42

Ruby on Rai

2009-12-17 09:49:18

Ruby代碼管理

2009-12-18 17:24:12

Ruby配置Mysql

2009-12-15 14:51:50

Ruby繼承
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)