Witam,
mam następujący problem, chciałbym w javie pobrać wartość zwracaną w kontrolce "oid". Dla przykładu kiedy robię zapytanie ldapsearch na linuxise: ./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"
otrzymuję wynik:
dn: dn
control: 1.3.6.1.4.1.637.81.2.10.10 false AgEB
objectClass: top
objectClass: ConfigOAM
confOAMId: 1
..
w javie wyglada to mniej wiecej tak:
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);
}
}
}
wynikeim tego Kodu jest:
Attributes:
supportedSASLMechanisms
configContext
supportedLDAPVersion
monitorContext
description
subschemaSubentry
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 1.3.6.1.4.1.637.81.2.10.5 1.3.6.1.4.1.637.81.2.10.4 1.3.6.1.4.1.637.81.2.10.3 1.3.6.1.4.1.637.81.2.10.2 1.3.6.1.4.1.637.81.2.10.1 1.3.6.1.4.1.637.81.2.10.8 1.3.6.1.4.1.637.81.2.10.7 1.3.6.1.1.21.2 entryDN namingContexts supportedExtension 1.3.6.1.4.1.1466.20037 1.3.6.1.1.21.3 1.3.6.1.1.21.1 1.3.6.1.4.1.4203.1.11.1 1.3.6.1.4.1.4203.1.11.3 structuralObjectClass objectClass
Moje pytanie to jak w javie wyświetlić również pozostałe informacje o kontrolce mianowicie: 1.3.6.1.4.1.637.81.2.10.10 false AgEB
Z góry wszystkim dziękuję za pomoc.