Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

LDAP - how to select a binary attribute in Java

Thread view: 
Bud - 08 Mar 2007 00:40 GMT
I'm using an InitialLdapContext object to perform a search on an
entry.

     results = ctx.search(searchBase, searchFilter, ctls);

Using the same searchBase and searchFilter, if the ctls
(SearchControls) list of requested attributes are strings the
execution of the search will give me a results with the requested
attribute values.  However, when the ctls has a binary attribute, that
attribute appears to be ignored in the results.

In my particular example I'm trying to acquire a "jpegPhoto" attribute
which is already identified as a binary item by the server.  I have
tried specifying the attribute as binary using "jpegPhoto;binary" with
no better success.  I have also tried insuring a binary object would
be returned by setting

     ctls.setReturningObjFlag(true);

with no success.

Can someone suggest what the problem might be or how I might narrow
the problem down?  If I use a LDAP browser (jXplorer or LDAP Studio) I
can view the stored jpegPhoto with no problem  It appears that only my
program has the problem.

I did discover that jXplorer doesn't use the
javax.naming.ldap.InitialLdapContext to gain access to the server.
Can that be my issue?
Brandon McCombs - 08 Mar 2007 02:06 GMT
> I'm using an InitialLdapContext object to perform a search on an
> entry.
[quoted text clipped - 16 lines]
>
> with no success.

jpegPhoto is one of the default binary attributes that are already
defined in JNDI so you shouldn't have to explicitly tell JNDI that it is
binary. With that said, I specify it for completeness in my code. Also,
specifying it as "jpegPhoto;binary" is incorrect unless the attribute is
literally defined as jpegPhoto;binary in the schema of the directory.
Since it is a standard binary attribute there shouldn't be any reason
for a standard directory server to do that. I know Sun, OpenLDAP, and
ADS do not (and my LDAP GUI client handles binary attributes just fine
with all 3 of those so I know).

> Can someone suggest what the problem might be or how I might narrow
> the problem down?  If I use a LDAP browser (jXplorer or LDAP Studio) I
> can view the stored jpegPhoto with no problem  It appears that only my
> program has the problem.

When you are parsing the attributes and their values from the
SearchResult object you have to put the value of the jpegPhoto attribute
into a byte array (byte[]) in order to properly use it. However, the
attribute will not even be returned if you do not specify it explicitly
(assuming you aren't just telling your directory server to return all
attributes by using the * character). It is also possible to not be
returned if the user you are using to connect to the server does not
have privileges to read jpegPhoto for all the objects that are returned
in the result set. Is jpegPhoto included in the returned attribute set?

> I did discover that jXplorer doesn't use the
> javax.naming.ldap.InitialLdapContext to gain access to the server.
> Can that be my issue?

I don't know what jXplorer is so it's hard to say whether it's your
problem or not. How does that integrate into your code that you are
trying to get working? Is it your code or jXplorer that you are having
problems with?

THat's all I can say for now until I understand your situation more.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.