-1

I recently wanted to integrate Active directory in one of my projects. I created web app with CodeIgniter and used this AD library to integrate AD.

https://github.com/kathmann/Auth_AD

Now it does everything I need, except I cannot get manager's samaccountname or email id.

For example I want to fetch one user 'xyz' all details, I used predefine function from the library which is

get_all_user_data('xyz');

This is getting me all the details and for manager, I am getting below details.

CN=ABC DEF, OU=Users,OU=example1,OU=example2,OU=Sites,DC=example3,DC=example4,DC=example5

Now I want to fetch samaccountname and email of the above. But i am not sure how to do it.

Just let me know what to code further and convert above string to samaccountname and email of the user.

I already saw this thread: ldap filter for distinguishedName

The person question is same as mine but I didn't understand what the answer says. I tried the answer but it gets all the user who has same manager instead the actual manager user.

halfer
  • 19,824
  • 17
  • 99
  • 186
Rcreators
  • 73
  • 11
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Sep 08 '18 at 18:14
  • @Rcreators - Do you have any update to share? Whether my answer helped? – Am_I_Helpful Oct 16 '18 at 06:52

1 Answers1

1

Since you've already found out the manager's value for the said user, you already have the CN value for the manager in the same DN.

Manager's DN = CN=ABC DEF,   # // OUs placed below for sake of understanding
OU=Users,OU=example1,OU=example2,OU=Sites,DC=example3,DC=example4,DC=example5

You should create another filter on this CN value of the manager ("CN=ABC DEF" for the manager derived above), and then retrieve the values of mail and samaccountname attribute.

Your search filter should be: "(&(objectCategory=person)(objectClass=user)(cn=ABC DEF))". Now you should be able to fetch this user (manager here) and its detailed information, based on this CN filter.

Am_I_Helpful
  • 18,735
  • 7
  • 49
  • 73