|
Directory SDK for Java 4.19 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnetscape.ldap.LDAPControl
Represents arbitrary control data that can be used with a a particular LDAP operation. LDAP controls are part of version 3 of the LDAP protocol.
LDAP controls allow you to extend the functionality of an LDAP operation. For example, you can use an LDAP control for the search operation to sort search results on an LDAP server.
An LDAP control can be either a server control or a client control:
An LDAP control consists of the following information:
To determine which server controls are supported by a particular server,
you need to search for the root DSE (DSA-specific entry, where DSA is
another term for "LDAP server") and find the values of the
supportedControl attribute. This attribute contains the
object IDs (OIDs) of the controls supported by this server.
The following section of code demonstrates how to get the list of the server controls supported by an LDAP server.
public static void main( String[] args )
{
LDAPConnection ld = new LDAPConnection();
try {
String MY_HOST = "localhost";
int MY_PORT = 389;
ld.connect( MY_HOST, MY_PORT );
try {
ld.authenticate( 3, "cn=myApp,ou=Directory Apps", "23skidoo" );
} catch( LDAPException e ) {
System.out.println( "LDAP server does not support v3." );
ld.disconnect();
System.exit(1);
}
String MY_FILT = "(objectclass=*)";
String MY_BASE = "";
String getAttrs[] = { "supportedControl" };
LDAPSearchResults res = ld.search( MY_BASE,
LDAPConnection.SCOPE_BASE, MY_FILT, getAttrs, false );
while ( res.hasMoreElements() ) {
LDAPEntry findEntry = (LDAPEntry)res.nextElement();
LDAPAttributeSet findAttrs = findEntry.getAttributeSet();
Enumeration enumAttrs = findAttrs.getAttributes();
while ( enumAttrs.hasMoreElements() ) {
LDAPAttribute anAttr = (LDAPAttribute)enumAttrs.nextElement();
String attrName = anAttr.getName();
System.out.println( attrName );
Enumeration enumVals = anAttr.getStringValues();
while ( enumVals.hasMoreElements() ) {
String aVal = ( String )enumVals.nextElement();
System.out.println( "\t" + aVal );
}
}
}
}
catch( LDAPException e ) {
System.out.println( "Error: " + e.toString() );
}
try {
ld.disconnect();
}
catch( LDAPException e ) {
System.exit(1);
}
System.exit(0);
}
If you compile and run this example against an LDAP server that supports v3 of the protocol, you might receive the following results:
supportedcontrol 1.2.840.113556.1.4.473 1.3.6.1.4.1.1466.29539.12 1.3.6.1.4.1.42.2.27.9.5.2 1.3.6.1.4.1.42.2.27.9.5.6 2.16.840.1.113730.3.4.12 2.16.840.1.113730.3.4.13 2.16.840.1.113730.3.4.14 2.16.840.1.113730.3.4.15 2.16.840.1.113730.3.4.16 2.16.840.1.113730.3.4.17 2.16.840.1.113730.3.4.18 2.16.840.1.113730.3.4.19 2.16.840.1.113730.3.4.2 2.16.840.1.113730.3.4.3 2.16.840.1.113730.3.4.4 2.16.840.1.113730.3.4.5 2.16.840.1.113730.3.4.9
For more information on LDAP controls, see RFC 2251.
LDAPv3.CLIENTCONTROLS,
LDAPv3.SERVERCONTROLS,
LDAPConnection.search(java.lang.String, int, java.lang.String, java.lang.String[], boolean),
LDAPConnection.getOption(int),
LDAPConnection.setOption(int, java.lang.Object),
LDAPConnection.getResponseControls(),
LDAPConstraints.getClientControls(),
LDAPConstraints.getServerControls(),
LDAPConstraints.setClientControls(netscape.ldap.LDAPControl),
LDAPConstraints.setServerControls(netscape.ldap.LDAPControl),
Serialized Form| Field Summary | |
static String |
MANAGEDSAIT
|
static String |
PWEXPIRED
|
static String |
PWEXPIRING
|
| Constructor Summary | |
LDAPControl()
Default constructor for the LDAPControl class. |
|
LDAPControl(String id,
boolean critical,
byte[] vals)
Constructs a new LDAPControl object using the
specified object ID (OID), "criticality" field, and
data to be used by the control. |
|
| Method Summary | |
Object |
clone()
Creates a copy of the control. |
String |
getID()
Gets the object ID (OID) of the control. |
byte[] |
getValue()
Gets the data in the control. |
boolean |
isCritical()
Specifies whether or not the control is critical to the LDAP operation. |
static LDAPControl[] |
newInstance(byte[] data)
Instantiates all of the controls contained within the LDAP message fragment specified by data and returns them in an LDAPControl
array. |
static void |
register(String oid,
Class controlClass)
Associates a class with an oid. |
String |
toString()
Return a string representation of the control for debugging |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final String MANAGEDSAIT
public static final String PWEXPIRED
public static final String PWEXPIRING
| Constructor Detail |
public LDAPControl()
LDAPControl class.
public LDAPControl(String id,
boolean critical,
byte[] vals)
LDAPControl object using the
specified object ID (OID), "criticality" field, and
data to be used by the control.
id - the object ID (OID) identifying the controlcritical - true if the LDAP operation should be
cancelled when the server does not support this control (in other
words, this control is critical to the LDAP operation)vals - control-specific dataLDAPConstraints.setClientControls(netscape.ldap.LDAPControl),
LDAPConstraints.setServerControls(netscape.ldap.LDAPControl)| Method Detail |
public String getID()
public boolean isCritical()
true if the LDAP operation should be cancelled when
the server does not support this control.public byte[] getValue()
public static void register(String oid,
Class controlClass)
throws LDAPException
LDAPControl, and should implement the LDAPControl(
String oid, boolean critical, byte[] value) constructor to
instantiate the control.
oid - the string representation of the oidcontrolClass - the class that instantatiates the control associated
with oid
LDAPException - If the class parameter is not
a subclass of LDAPControl or the class parameter does not
implement the LDAPControl(String oid, boolean critical, byte[] value)
constructor.
public static LDAPControl[] newInstance(byte[] data)
throws IOException
LDAPControl
array. This fragment can be either the entire LDAP message or just the
control section of the message.
If an exception occurs when instantiating a control, that control is
returned as a basic LDAPControl.
data - the LDAP message fragment in raw BER format
LDAPControl array containing all of the controls
from the message fragment.
java.lang.IOException - If the data passed to this method
is not a valid LDAP message fragment.
IOExceptionregister(java.lang.String, java.lang.Class)public Object clone()
public String toString()
|
Directory SDK for Java 4.19 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||