Hi to all, I need some help with java to retrieve the eDirectory GUID. I
know it's a binary data field and I need to decode it to read the value,
but I'm not able to retrieve anything, even if I name the attribute
because it is operational.

This is my code. What am I doing wrong?

import com.novell.ldap.*;

import java.io.UnsupportedEncodingException;


public class GuidReader {
public static void main( String[] args ) {
String loginDN = "cn=admin,o=system";
String password = "MYPASSWORD";
String searchBase = "MYCONTEXT";
String searchFilter = "(cn=MYUSERNAME)";
int searchScope = LDAPConnection.SCOPE_SUB;

LDAPConnection lc = new LDAPConnection();
try {
lc.connect( "MYIPADDRESS", 389 );
try {
lc.bind( LDAPConnection.LDAP_V3, loginDN,
password.getBytes("UTF8"));
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
LDAPSearchResults searchResults = lc.search(
searchBase,
searchScope,
searchFilter,
null,
false );
while ( searchResults.hasMore() ) {
LDAPEntry nextEntry = null;
try {
nextEntry = searchResults.next();
} catch(LDAPException e ) {
System.out.println("Error: " + e.toString());
continue;
}
LDAPAttribute attribute =
nextEntry.getAttribute("objectGuid");
if (attribute == null) System.out.println("not
returned");
attribute = nextEntry.getAttribute("GUID");
if (attribute == null) System.out.println("not
returned");
attribute = nextEntry.getAttribute("cn");
if (attribute == null) System.out.println("not
returned");
else System.out.println("returned");


} catch( LDAPException e ) {
System.out.println("Error " + e.toString() );
}
}

}


If I run it, i get this result:

not returned
not returned
returned

Thank you,

Natan Sanson


--
nsanson
------------------------------------------------------------------------
nsanson's Profile: http://forums.novell.com/member.php?userid=1637
View this thread: http://forums.novell.com/showthread.php?t=410589