ben
May 27, 2009

Retrieve EMail address from Active Directory in a bash script

Hi Everyone,

I need to create a script integrated with Samba that retrieves email addresses from given names, let me explain it better  ok ?

I've a Linux Machine into an Active Directory forest, i can get information for current AD usernames, something like:
myserver:~# wbinfo -i andrea
andrea:*:10014:10001:Andrea Benini:/home/DOMAIN/andrea:/bin/bash

I need to retrieve email address for the specified used, possibly using only bash scripts and utilities found in my system (AD integration through Samba+winbindd), is there a way to do it ?

I've now solved with PHP but Jesse solution is what I was looking for, nice...

I've now solved with PHP but Jesse solution is what I was looking for, nice trick :-)

Like  (0 likes)

I've now solved with PHP but Jesse solution is what I was looking for, nice...

I've now solved with PHP but Jesse solution is what I was looking for, nice trick :-)

Like  (0 likes)

I've now solved with PHP but Jesse solution is what I was looking for, nice...

I've now solved with PHP but Jesse solution is what I was looking for, nice trick :-)

Like  (0 likes)

Using the ldapsearch tool is a quick and easy way to pull information from AD...

Using the ldapsearch tool is a quick and easy way to pull information from AD.

the following command (substitute your directory info) can easily pull an email address from AD

ldapsearch -x -h -s sub -b dc=,dc=COM -D "CN=your id,DC=,DC=COM" -W '(&(objectclass=User)(givenName=firstname)(sn=lastname))' mail

wrapping the above in a shell script is trivial. use the command above and leave off 'mail' at the end. it should bring up all attributes that you can see.

Like  (0 likes)

Using the ldapsearch tool is a quick and easy way to pull information from AD...

Using the ldapsearch tool is a quick and easy way to pull information from AD.

the following command (substitute your directory info) can easily pull an email address from AD

ldapsearch -x -h -s sub -b dc=,dc=COM -D "CN=your id,DC=,DC=COM" -W '(&(objectclass=User)(givenName=firstname)(sn=lastname))' mail

wrapping the above in a shell script is trivial. use the command above and leave off 'mail' at the end. it should bring up all attributes that you can see.

Like  (0 likes)

Using the ldapsearch tool is a quick and easy way to pull information from AD...

Using the ldapsearch tool is a quick and easy way to pull information from AD.

the following command (substitute your directory info) can easily pull an email address from AD

ldapsearch -x -h -s sub -b dc=,dc=COM -D "CN=your id,DC=,DC=COM" -W '(&(objectclass=User)(givenName=firstname)(sn=lastname))' mail

wrapping the above in a shell script is trivial. use the command above and leave off 'mail' at the end. it should bring up all attributes that you can see.

Like  (0 likes)

found a link explaining capabilities of ldap-search package and various...

found a link explaining capabilities of ldap-search package and various utilities but i think it's too limited, in my case I need to retrieve email address as well as other information from AD Tree, just solved using PHP. Of course Python and other folks can do the same as well

Like  (0 likes)

found a link explaining capabilities of ldap-search package and various...

found a link explaining capabilities of ldap-search package and various utilities but i think it's too limited, in my case I need to retrieve email address as well as other information from AD Tree, just solved using PHP. Of course Python and other folks can do the same as well

Like  (0 likes)

found a link explaining capabilities of ldap-search package and various...

found a link explaining capabilities of ldap-search package and various utilities but i think it's too limited, in my case I need to retrieve email address as well as other information from AD Tree, just solved using PHP. Of course Python and other folks can do the same as well

Like  (1 like)

Forgot to mention a thing:I've tried to get some info from AD with PHP and I...

Forgot to mention a thing:
I've tried to get some info from AD with PHP and I can, is there a way to get something without installing the whole php-cli and libs ?

Thanks
Ben

Like  (0 likes)

Pages

Click Here!