转载 LDAP command or method

LDAP (Lightweight Directory Access Protocol) 是一種輕量的目錄存取協定,提供客戶從各個角落連接到目錄伺服器中。
ldap_add: 增加 LDAP 名錄的條目。 
ldap_mod_add: 增加 LDAP 名錄的屬性。
 ldap_mod_del: 刪除 LDAP 名錄的屬性。 
ldap_mod_replace: 新的 LDAP 名錄取代舊屬性。
 ldap_bind: 繫住 LDAP 目錄。 
ldap_close: 結束 LDAP 連結。
 ldap_connect: 連上 LDAP 伺服器。
 ldap_count_entries: 搜尋結果的數目。
 ldap_delete: 刪除指定資源。
 ldap_dn2ufn: 將 dn 轉成易讀的名字。
 ldap_explode_dn: 切開 dn 的欄位。
 ldap_first_attribute: 取得第一筆資源的屬性。
 ldap_first_entry: 取得第一筆結果代號。
 ldap_free_result: 釋放傳回資料記憶體。
 ldap_get_attributes: 取得傳回資料的屬性。
 ldap_get_dn: 取得 DN 值。
 ldap_get_entries: 取得全部傳回資料。
 ldap_get_values: 取得全部傳回值。
 ldap_list: 列出簡表。
 ldap_modify: 改變 LDAP 名錄的屬性。
 ldap_next_attribute: 取得傳回資料的下筆屬性。
 ldap_next_entry: 取得下一筆結果代號。
 ldap_read: 取得目前的資料屬性。
 ldap_search: 列出樹狀簡表。
 ldap_unbind: 結束 LDAP 連結。

 假設 目前公司的網址信箱1111@222.333.44
 strSearchBase = "LDAP://DC=222,DC=333,DC=44w" '路徑 
strFilter = "((objectCategory=person))" '查詢的條件 
strAttribs = "sAMAccountName,Mail" '列出的資訊(sAMAccountName = 使用者帳號、Mail= 使用者mail) 
strScope = "subtree" '表示要搜尋整個子樹 
Dim strCommandText 
strCommandText = "<" & strSearchBase & ">;" _ & strFilter & ";" & strAttribs & ";" & strScope 
Dim oConnection Set oConnection = Server.CreateObject("ADODB.Connection")
Dim oCommand Set oCommand = Server.CreateObject("ADODB.Command") oConnection.Provider = "ADsDSOObject" 
oConnection.Open "Active Directory Provider" 
set oCommand.ActiveConnection = oConnection 
oCommand.CommandText = strCommandText 

Dim oRecordset Set oRecordset = oCommand.Execute(strCommandText)

if (Not oRecordset.EOF) then 
For Each oField in oRecordset.Fields 
Response.Write oField.Name 
next 
end if 

While Not oRecordset.EOF 
For Each oField in oRecordset.Fields 
Response.Write oField.Value 
next oRecordset.MoveNext 

Wend

posted on 2008-08-06 21:23  Good life  阅读(253)  评论(0编辑  收藏  举报