Re: Binary Data from JNDI Plugin
Re: Binary Data from JNDI Plugin
- Subject: Re: Binary Data from JNDI Plugin
- From: Anthony Glover <email@hidden>
- Date: Thu, 11 Nov 2004 10:23:53 -0600
o.k. I got this to work finally. Instead of creating a custom plug-in,
I found out through a little research that I can add the binary
property to a file called "jndi.properties" in the $JAVA_HOME/lib
directory. So, I now have a file that contains the following:
java.naming.ldap.attributes.binary=objectGUID
With this in place, and the objectGUID configured as shown below,
EOModeler now shows me the binary value.
Thanks,
Tony
On Nov 10, 2004, at 11:54 AM, Chuck Hill wrote:
Just a quick thought: You said "What you actually get back is the
'pointer' to the byte array" and "I have done this with a small test
and everything works o.k. "
Were you getting the data OK, or just the handle? I'm thinking that
you might need something more than your attribute definition below.
Chuck
On Nov 9, 2004, at 1:31 PM, Anthony Glover wrote:
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:
village.net
This email sent to email@hidden
--
Practical WebObjects - a book for intermediate WebObjects developers
who want to increase their overall knowledge of WebObjects, or those
who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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