(open)Ldap query for dn of inetOrgPerson containing an alias
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
(open)Ldap query for dn of inetOrgPerson containing an alias
G'day y'all,
Hoping someone can help me get the correct search/filter setup for this situation; been searching the interwebs for a while now, and still cannot even find if someone has asked this one before.
The setup is as follows:
I have an ou, called contacts. The ou contains inetOrgPerson objects. The purpose is to have a single object containing the contactinformation of a set of users that are referenced as aliases; those users are setup below:
I have another ou, called users. This ou contains the actual user.
So, now I have to find the 'contact' that has the aliasedObjectName <dn of the user>.
For simplicity let's have this 'user' object: 'cn=Ramurd,ou=users,dc=environment,o=org"
It is referenced in one of the contact-objects, and I'd like to know which one.
So I tried a few filters:
(&(objectClass=inetOrgPerson)(aliasedObjectName=cn=Ramurd,ou=users,dc=environment,o=org))
But it returns the alias (=user) not the contact.
'(objectClass=*)' '(aliasedObjectname=cn=Ramurd,ou=users,dc=environment,o=org)' (with ldapsearch) returns all contacts, not only the one that has the given alias...
Tried a few more, but got either the above results or none at all. (and for the test I know I should get exactly one result)
For now, until I know of a better solution, I have created this solution (in php style)
First I search the existing inetOrgPersons, I iterate over each to see if they have an 'aliasedObjectName' and then test if one of those is the dn of the user I'm searching for.
If so, I know I found the dn.
Codewise, it goes like this (and it is a style I was hoping to avoid):
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.