Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read photo LDAP Attribut as a String

Status
Not open for further replies.

tiger311

Programmer
Sep 22, 2011
3
DE
Hello,
I need to write an application which read the value from active directory "photo" attribut.I have to get the value of this attribut.
This value contains the path of the image file like:
" user_ou=users_ou=ham_ou=reu_dc=test-ad_dc=test.jpg"
My code is:

String searchFilter = "(&(objectClass=user)(" + searchPara + "=" + searchText + "))";
NamingEnumeration<SearchResult> search = ctx.search("DC=hsdg-ad,DC=int", searchFilter, searchControls);
while (search.hasMoreElements()) {
try {
User userData = new User();
result searchResult = search.nextElement();
String test = result.getAttributes().get(PHOTO).get().toString()

// hier I like to put this value into a String "test" but I get that like "*** test: [B@1569009"
}
}

Can somebody tell me how can I read the photo attribute value and get the value like " user_ou=users_ou=ham_ou=reu_dc=test-ad_dc=test.jpg"?


Thank you in advance!
 
Well, this part of your code

Code:
result.getAttributes().get(PHOTO).get()

is returning an Object, but not a String so if you call toString will get that output.

You could try

Code:
result.getAttributes().get(PHOTO).size()
to see wether it's a simple or complex attribute and
Code:
result.getAttributes().get(PHOTO).class
to see what class it is.


Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top