Announcement Announcement Module
Collapse
No announcement yet.
how to execute extended operations in spring ldap Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to execute extended operations in spring ldap

    Hi....

    I dont hav any idea how to execute extended operations in spring ldap.First i was using netscape ldap connection and i am able to execute extended operation using ldapconnection...Plz reply... I am giving a snippet of code using netscape ldap connection for extended operation...its working So plz tel me how can i execute extended op in spring ldap..

    LDAPConnection ldapTemplate;
    LdapExecuteArgument executeArgs = new LdapExecuteArgument(objectId,methodID,parameters);
    byte[] vals = new byte[]{};
    vals = executeArgs.constructBytes(executeArgs.constructBE R());

    LDAPExtendedOperation exop = null;
    String OID = "0.0.17.1218.127.127.10";
    exop = new LDAPExtendedOperation(OID, vals );
    LDAPExtendedOperation exres = null;
    exres = ldapTemplate.extendedOperation( exop );//no such method in spring ldaptemplate
    LdapExecuteResult res = new LdapExecuteResult(exres.getValue());

  • #2
    Extended operations is supported by JNDI. However, we have no explicit support for the extendedOperation method in LdapTemplate. Chapter 5 in the Spring LDAP reference manual describes how to add missing API methods.

    Perhaps you could try something like this:

    Code:
       MyExtendedResponse response = (MyExtendedResponse) ldapTemplate.executeReadOnly(new ContextExecutor() {
          public Object executeWithContext(DirContext ctx)
                throws javax.naming.NamingException {
             if (!(ctx instanceof LdapContext)) {
                throw new IllegalArgumentException(
                   "Extended operations require LDAPv3 - "
                   + "Context must be of type LdapContext");
             }
             LdapContext ldapContext = (LdapContext) ctx;
             return ldapContext.extendedOperation(new MyExtendedRequest());
          }
       });
    You must write your own implementations of the ExtendedRequest/ExtendedResponse interfaces:

    Code:
       private static class MyExtendedRequest implements ExtendedRequest {
          ...
          public ExtendedResponse createExtendedResponse(String id, byte[] berValue, int offset, int length)
                throws NamingException {
             return new MyExtendedResponse(id, berValue, offset, length);
          }
       }
    
       private static class MyExtendedResponse implements ExtendedResponse {
          MyExtendedResponse(String id, byte[] berValue, int offset, int length)
                throws NamingException { ... }
          ...
       }

    Comment

    Working...
    X