School me on LDAP queries


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting School me on LDAP queries
# 1  
Old 06-11-2014
School me on LDAP queries

10.9.3 BASH

I have what I think is a simple project, but I am having trouble digesting tutorials on the web so I was hoping somebody could clarify. I have been looking at ldap and ldapsearch commands.

My company has an LDAP directory which I would like to query to pull information such as name, dept #, phone number etc. The search string that I have to work with is an email address.

Can somebody provide some insight, or point me in the direction on how I can get this done in a BASH script?
# 2  
Old 06-11-2014
You will need to browse AD and find the correct OU and DC plus the fields you are interested most organisations will populate OU and different fields so this is usually the biggest hurdle

Here is an example of searching for mail address and displaying some info:

Code:
MAIL="auser@acme.com"
ldapsearch -h mydchost.acme.local -b 'OU=Acme Group,DC=acme,DC=local' -D 'ACME\sudo' -W "(&(objectclass=*)(mail=$MAIL))" cn mail department phone

You can try running without specifying any fields and try an pick out what you are interested in:

Code:
ldapsearch -h mydchost.acme.local -b 'OU=Acme Group,DC=acme,DC=local' -D 'ACME\sudo' -W "(&(objectclass=*)(mail=$MAIL))"

This User Gave Thanks to Chubler_XL For This Post:
# 3  
Old 06-12-2014
Quote:
Originally Posted by Chubler_XL
You will need to browse AD and find the correct OU and DC plus the fields you are interested most organisations will populate OU and different fields so this is usually the biggest hurdle

Here is an example of searching for mail address and displaying some info:

Code:
MAIL="auser@acme.com"
ldapsearch -h mydchost.acme.local -b 'OU=Acme Group,DC=acme,DC=local' -D 'ACME\sudo' -W "(&(objectclass=*)(mail=$MAIL))" cn mail department phone

You can try running without specifying any fields and try an pick out what you are interested in:

Code:
ldapsearch -h mydchost.acme.local -b 'OU=Acme Group,DC=acme,DC=local' -D 'ACME\sudo' -W "(&(objectclass=*)(mail=$MAIL))"

Thanks for the reply- 2 questions? Is there a common was to browse the Active Directory to get OU and DC information? I do not host/admin the server.

Code:
'OU=Acme Group,DC=acme,DC=local' -D 'ACME\sudo'

I'm familiar with o/ou but not DC. Can you explain the DC fields as well as the ACME\sudo field?

Much appreciated.
# 4  
Old 06-12-2014
Try downloading the application called GetMyDN.exe in domain to get your own Distinguished Name. Then the last part before the "User Accounts" or such is you value you want to start your ldapsearch at.

For example it may return something like this

Code:
 CN=Sudo user,OU=Information Technology,OU=New York,OU=Corporate Services,OU=User Accounts,OU=Acme Group,DC=acme,DC=local

It can be downloaded from

http://download.softerra.com/files/GetMyDN.zip


replace ACME\sudo with your login, format is DOMAIN\userid. The assumption here is that you have access to browse the domain.
This User Gave Thanks to Chubler_XL For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Solaris

LDAP Client not connecting to LDAP server

I have very limited knowledge on LDAP configuration and have been trying fix one issue, but unsuccessful. The server, I am working on, is Solaris-10 zone. sudoers is configured on LDAP (its not on local server). I have access to login directly on server with root, but somehow sudo is not working... (9 Replies)
Discussion started by: solaris_1977
9 Replies

2. UNIX for Advanced & Expert Users

something like LDAP Administrator 2011.1 "LDAP-SQL" but for the CLI

Hi I am searching a tool like "LDAP Administrator 2011.1"/ "LDAP-SQL" but for the CLI. Wish to use LDAP-SQL in scripts (non Windows GUI environment) http://ldapadministrator.com/resources/english/2011.1/images/sqlquery_large.png Softerra LDAP Administrator 2011.1 - What's New OS is... (2 Replies)
Discussion started by: slashdotweenie
2 Replies

3. Shell Programming and Scripting

School assignment

Hi, I have assignment from school. Please help me write the script for following example Using "eval", write a program called "recho" that prints its arguments in reverse order. For example, $recho one two three should produce three two one (1 Reply)
Discussion started by: sdp5628
1 Replies

4. Shell Programming and Scripting

Help with school homework

ok its a simple script, but i can't get it to run right. i'm totally lost. can anyone help me with this. heres the question........create a shell script called minute.bash that starts the command labs/bash/count.sh and lets it run for 1 minute and then stops it. count.sh is a simple... (1 Reply)
Discussion started by: AtomJ22
1 Replies

5. OS X (Apple)

school unix

i have really no administrative privileges at my school how can i add my self to passwd and create a root account? (6 Replies)
Discussion started by: shanepowell
6 Replies
Login or Register to Ask a Question