Announcement Announcement Module
Collapse
No announcement yet.
Can't the currect objectGUID by using LdapTemplat.search(..) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can't the currect objectGUID by using LdapTemplat.search(..)

    Hi there,

    I was trying to get the objectGUID from Active Directory. Unfortunately, I couldn't convert the object to byte[] which get from LdapTemplat.search(..), and it showed me following error messages:

    java.lang.ClassCastException: java.lang.String cannot be cast to [B

    Also, when I was trying to output the objectGUID object directly to the console, it showed as following.

    Z=�O��G�S�P��7

    Again, I tried to convert it to String and then convert the String to byte[], but the result was not a 16-byte any more.

    So, my question is that if the objectGUID object has been encoded when Spring LDAP load it from AD.
    If so, how to decode it please?
    And if not, how to get objectGUID and retrieve it to a String?


    Thanks.
    Dean

  • #2
    I debugged and entered into method
    public void search(SearchExecutor se, NameClassPairCallbackHandler handler, DirContextProcessor processor) of LdapTemplate Class.

    ...........
    NamingEnumeration results = null;
    RuntimeException ex = null;
    try {
    processor.preProcess(ctx);
    results = se.executeSearch(ctx); // I believe this line is to get all of the attributes.

    while (results.hasMore()) {
    NameClassPair result = (NameClassPair) results.next();
    handler.handleNameClassPair(result);
    }
    }
    ..............

    Inspected results , and I found that the bad objectGUIDs have been there already.

    Comment


    • #3
      I also used the JNDI way which refers this link
      https://forums.oracle.com/thread/1157698
      And it works.

      Based this point, I was confused worse.

      Please give me a hint. Thanks.

      Comment


      • #4
        I've figure it out by referring this post.

        http://forum.springsource.org/showth...ght=objectGUID

        Comment

        Working...
        X