gpt4 book ai didi

java - 如何使用 com.novell.ldap 从 LDAP 获取 "supportedControl"

转载 作者:行者123 更新时间:2023-11-30 04:14:55 26 4
gpt4 key购买 nike

我想从 LDAP 的控件 oid 中获取值:例如,当我使用 Linux ldapsearch 时:

ldapsearch -H ldap://host:port -x -wsecret -D "cn=manager,managedElementId=HSS1"
-b "dn" "objectClass=ConfigOAM" -E"1.3.6.1.4.1.637.81.2.10.10"

我得到结果:

...
**control: 1.3.6.1.4.1.637.81.2.10.10 false AgEB**
objectClass: top
objectClass: ConfigOAM
confOAMId: 1
...

我的java代码看起来:

LDAPConnection connection = new LDAPConnection();
connection.connect(hostName, port);
connection.bind(LDAPConnection.LDAP_V3, userDN, password);

String returnedAttributes[] = {"+", "*"};
boolean attributeOnly = false;
String oid;
LDAPSearchResults results = connection.search("", LDAPConnection.SCOPE_BASE, "(objectClass=*)", returnedAttributes, attributeOnly);

LDAPEntry entry = results.next();
System.out.println("\n" + entry.getDN());
System.out.println(" Attributes: ");
LDAPAttributeSet attributeSet = entry.getAttributeSet();
Iterator allAttributes = attributeSet.iterator();

while(allAttributes.hasNext()) {
LDAPAttribute attribute = (LDAPAttribute)allAttributes.next();
String attrName = attribute.getName();
System.out.println(" " + attrName);
Enumeration allValues = attribute.getStringValues();

while(allValues.hasMoreElements()) {

oid = (String) allValues.nextElement();
if ( (attrName.equalsIgnoreCase("supportedExtension")) || (attrName.equalsIgnoreCase("supportedControl"))) {
System.out.println(" " + oid);
}
}
}
<小时/>

结果是:

    ...

supportedControl

2.16.840.1.113730.3.4.2

1.2.840.113556.1.4.319

1.2.826.0.1.3344810.2.3

1.3.6.1.1.12

1.3.6.1.4.1.637.81.2.10.11

**1.3.6.1.4.1.637.81.2.10.10**

1.3.6.1.4.1.637.81.2.10.9

1.3.6.1.4.1.637.81.2.10.6

...

请建议我或建议我如何在java中获得附加值“false AgEB”,就像我在ldapsearch中获得它一样?

最佳答案

您需要将控件添加到搜索请求并能够解释响应。

有一些可用的示例: http://www.novell.com/documentation/developer/samplecode/jldap_sample/

-吉姆

关于java - 如何使用 com.novell.ldap 从 LDAP 获取 "supportedControl",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18642152/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com