Binary Data from JNDI Plugin
Binary Data from JNDI Plugin
- Subject: Binary Data from JNDI Plugin
- From: Anthony Glover <email@hidden>
- Date: Tue, 9 Nov 2004 15:31:40 -0600
I'm at my wits end and need some help guys....please. Using EOModeler,
I have reverse engineered my Microsoft ADS server's LDAP schema, and in
particular the User (similar to inetorgperson) class. I can query
objects of this class no problem. However, there is one field in
particular that I need access to - objectGUID. Here is the pertinent
information from the EOModel for this field as it was reverse
engineered by EOModeler:
{
allowsNull = Y;
columnName = objectGUID;
externalType = "Octet String";
name = objectGUID;
valueClassName = NSData;
}
This field is a binary value on the ADS, but by default, LDAP/JNDI
retrieves all values as UTF-8 encoded strings (I think). Unfortunately,
the binary values cannot be fully translated to UTF-8 strings; so, the
values I get back are useless (contains UTF-8 replacement character).
If one is just using plain Java and JNDI, the way to get around this is
to add the following line to the function that creates the ldap
directory context:
env.put("java.naming.ldap.attribute.binary", "objectGUID" );
This tells JNDI to return the objectGUID as a binary object. This is
done by default for fields like photo and userCertificate. What you
actually get back is the 'pointer' to the byte array instead of a
string value. I have done this with a small test and everything works
o.k. In order to make my WebObjects application do the same, I created
a custom LDAPPlugIn (see below) with the additional line. However, it
does not seem to help.
Does anyone have experience retrieving binary data (and specifically
objectGUID) from an LDAP/ADS server? Any help would be much
appreciated.
Thanks,
Tony
-------
public class MyLDAPPlugIn extends LDAPPlugIn {
public MyLDAPPlugIn() {
super();
}
public InitialDirContext createInitialDirContext( JNDIAdaptor
adaptor ) throws JNDIAdaptorException {
if (adaptor == null) {
throw new JNDIAdaptorException("adaptor can not be null.");
}
NSDictionary cd = adaptor.connectionDictionary();
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, cd.objectForKey(
adaptor.InitialContextFactoryKey ) );
env.put(Context.PROVIDER_URL, cd.objectForKey(
adaptor.ServerUrlKey ) );
//env.put(Context.SECURITY_PROTOCOL, "ssl");
env.put(Context.SECURITY_AUTHENTICATION, cd.objectForKey(
adaptor.AuthenticationMethodKey ) );
env.put(Context.SECURITY_PRINCIPAL, cd.objectForKey(
adaptor.UsernameKey ) );
env.put(Context.SECURITY_CREDENTIALS, cd.objectForKey(
adaptor.PasswordKey ) );
env.put("java.naming.ldap.attribute.binary", "objectGUID" );
try {
LdapContext ctx = new InitialLdapContext(env, null);
return (InitialDirContext)ctx;
} catch (NamingException e) {
throw new JNDIAdaptorException( e );
}
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden