從 OpenLDAP 檢索操作屬性

從 OpenLDAP 檢索操作屬性

我一直在嘗試找到一些有關如何從 OpenLDAP 檢索操作屬性的好文件。

我想透過執行 LDAP 搜尋來檢索 LDAP 伺服器的基本專有名稱。

當我明確請求 NamingContexts 屬性時,為什麼我的搜尋不起作用?我被告知需要在屬性清單中添加加號(“+”)。

如果是這種情況,我應該刪除「namingContexts」屬性還是同時擁有這兩個屬性?

ldapsearch -H ldap://ldap.mydomain.com -x -s base -b "" +
# note the + returns operational attributes

編輯:請注意,請求的屬性看起來像是空的。加號不應該在屬性清單中嗎?http://www.zytrax.com/books/ldap/ch3/#operational

參考:使用 OpenLDAP 的加號運算符

答案1

當我明確請求 NamingContexts 屬性時,為什麼我的搜尋不起作用?

什麼不起作用?您收到錯誤嗎?

當有加號時,無論是否有新增namingContexts,它都會傳回所有屬性。

使用:

ldapsearch -x -H ldap://ldap.example.com -s base -b "" namingContexts

返回:

# extended LDIF
#
# LDAPv3
# base <> with scope baseObject
# filter: (objectclass=*)
# requesting: namingContexts 
#

#
dn:
namingContexts: o=example.com

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1

它也使用以下方式列出:

ldapsearch -x -H ldap://ldap.example.com -s base -b "" +

返回:

# extended LDIF
#
# LDAPv3
# base <> with scope baseObject
# filter: (objectclass=*)
# requesting: + 
#

#
dn:
structuralObjectClass: OpenLDAProotDSE
namingContexts: o=example.com
supportedControl: 2.16.840.1.113730.3.4.18
supportedControl: 2.16.840.1.113730.3.4.2
supportedControl: 1.3.6.1.4.1.4203.1.10.1
supportedControl: 1.2.840.113556.1.4.1413
supportedControl: 1.2.840.113556.1.4.1339
supportedControl: 1.2.840.113556.1.4.319
supportedControl: 1.2.826.0.1.334810.2.3
supportedExtension: 1.3.6.1.4.1.1466.20037
supportedExtension: 1.3.6.1.4.1.4203.1.11.1
supportedExtension: 1.3.6.1.4.1.4203.1.11.3
supportedFeatures: 1.3.6.1.4.1.4203.1.5.1
supportedFeatures: 1.3.6.1.4.1.4203.1.5.2
supportedFeatures: 1.3.6.1.4.1.4203.1.5.3
supportedFeatures: 1.3.6.1.4.1.4203.1.5.4
supportedFeatures: 1.3.6.1.4.1.4203.1.5.5
supportedLDAPVersion: 2
supportedLDAPVersion: 3
supportedSASLMechanisms: DIGEST-MD5
supportedSASLMechanisms: CRAM-MD5
subschemaSubentry: cn=Subschema

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1

答案2

我的 slapd.conf 中的第一個存取規則明確地確保這是允許的;確保你有類似的東西:

# Let all clients figure out what auth mechanisms are available, determine
# that TLS is okay, etc
access to dn.base=""
        by *            read

相關內容