LDAP search filter for multi value attribute

I have a ldap db and on of its attributes is multi-valued. When i do an ldapsearch on an user entry and ask for result of that attribute for example
ldapsearch -h -p -D <dn> -b -s "(cn=AJ)" myattribute
It returns for cn=AJ
Is there any way that i can get only the one result that i require. For example if i want only city out of that multivalued attribute it should only return "myattribute=city,baltimore".
I have tried "ldapsearch -h -p -D <dn> -b -s "(&(cn=AJ)(myattriibute=city*))" myattribute"
but this doesn't seem to work and returns all results as above.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

shrikrishnasamantAuthor Commented:
This is kind of very urgent
> Is there any way that i can get only the one result that i require.

No way. ldapsearch will always return all attributes with the given name 'myattribute'.

You may perform a post processing of these results to extract any special value like:
dapsearch -h -p -D <dn> -b -s "(cn=AJ)" myattribute | grep 'myaddribute=city,'

But this is _not_ the right way of keeping data in LDAP. All attributes having the same name are considered having equal semantics. If you need such different values, you should use different attributes. You might need to redesign entire LDAP tree. There are many standard LDAP schemes that allows you to express all that fields.
For your example there is a standard cosine schema: http://www.faqs.org/rfcs/rfc1274.html

You may use 2 object-classes 'locality' and 'country' for your entry:



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.