UNIX Script to query Active Directory: give cn (NT login name) and receive mail (Email address)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting UNIX Script to query Active Directory: give cn (NT login name) and receive mail (Email address)
# 1  
Old 05-18-2010
UNIX Script to query Active Directory: give cn (NT login name) and receive mail (Email address)

Hi folks

I need to write UNIX script (with ldapsearch) to query Active Directory. Input is NT login name and output is Email address.

Attached a screenshot of Sysinternals "AD Explorer". I need to do the same in CLI.

Image

I am absolute LDAP/ldapsearch noob.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Forum Support Area for Unregistered Users & Account Problems

Further to my query re: failed attempt to change email address on existing account

Neo Thanks for your reply to my original post, entitled "Problem changing the email address associated with my unix.com account". I am unable to reply to you in that thread, as I am unable to log-on to unix.com! From what you said about purging dormant accounts, it is likely that my account... (1 Reply)
Discussion started by: irb
1 Replies

2. Proxy Server

Solaris 11.1 login authenticate with windows active directory

Hi, is that possible to login to solaris 11.1 authenticate with windows active directory? the user id is created in the windows active directory. Environment: Solaris 11.1 Windows 2012 Active Directory (3 Replies)
Discussion started by: freshmeat
3 Replies

3. Shell Programming and Scripting

Run a script when I receive an email

Hi expert I wish to start a shell script when I receive an email. I modified the aliases file and I add this string as400nag: "|/home/nag-script/startstop/AS400-Boot.sh The solution works . When the as400nag user receive an email the /home/nag-script/startstop/AS400-Boot.sh starts .but... (3 Replies)
Discussion started by: emi65
3 Replies

4. Red Hat

How to change sender email address in mail -s command

Just having trouble trying to figure out what the option is. When I do mail -s "Subject" someuser@example.com I can't seem to specify "from" or "sender" option as I need it for my task. I tried using --f or -f though it didn't work. Can someone please tell me what other option... (0 Replies)
Discussion started by: rockf1bull
0 Replies

5. Shell Programming and Scripting

keep mail command active inside a script on unix

well, I have a script with this code inside: nohup /usr/sbin/auditstream | /usr/sbin/auditselect -m -e "event== USER_Create || event== USER_Remove || event== USER_Change || event== GROUP_Create || event== GROUP_Remove || event== GROUP_Change || event== PASSWORD_Change " | /usr/sbin/auditpr -h... (4 Replies)
Discussion started by: iga3725
4 Replies

6. Shell Programming and Scripting

I could not receive the mail sent from the unix server using 'mailx'

Hi All, I have sent a mail to my gmail id using the below command. echo " " | mailx -s "sub" myid@gmail.com I didn't get any error notification. But still I didn't receive that mail still.. please help me to learn how to send mail to other provider (Yahoo/gmail) from unix server.... (1 Reply)
Discussion started by: little_wonder
1 Replies

7. UNIX for Dummies Questions & Answers

I can send but cannot receive mail with unix?

Hi all, First post! I have just discovered that I can use unix to send mail to a mail address. I normally use entourage for my mail. This unix mail is very intriguing to me, but something is not working... I tried the search, but could not find the answer... This works: (in terminal)... (1 Reply)
Discussion started by: bjorn
1 Replies

8. Shell Programming and Scripting

how to know if the mailx command really sends the mail to the email address?

Hi guys, I have a question about the returning message of the mailx command. if I run a mailx command, how can I know if the email has been sent to the email address? If the email address doesn't exist, is there any error message returned? If yes, how can I get the error message? Thanks... (3 Replies)
Discussion started by: sheenshine
3 Replies

9. UNIX for Dummies Questions & Answers

Receive e-mail on unix box

Hi, I am not sure if it is a good question or not. Is there a unix utility which can be configured with exchange server and then receive e-mails? Thanks! (4 Replies)
Discussion started by: DejaVu
4 Replies
Login or Register to Ask a Question
KRB5-SYNC(8)							     krb5-sync							      KRB5-SYNC(8)

NAME
krb5-sync - Synchronize passwords and status with Active Directory SYNOPSIS
krb5-sync [-d | -e] [-p password] user krb5-sync -f file DESCRIPTION
krb5-sync provides a command-line interface to the same functions provided by the password and status synchronization plugin. It can push a new password to Active Directory (actually, to any password store that supports the Kerberos set-password protocol) or activate or deactivate an account in Active Directory. To synchronize passwords, provide the -p option and specify the password. Note that the password is given on the command line and must be quoted if it contains special characters, and the password will be exposed to any other users on the system where this command is run. This is useful primarily for testing and should not be used with production passwords. Synchronization to Active Directory will be attempted based on the configuration in krb5.conf (see below). To enable or disable an account, provide the -e or -d option respectively. These options can also be provided in conjunction with the -p option to take both actions at once. In either case, user should be the principal name for which these actions should be taken. user may be either unqualified or in the local realm; either way, the Active Directory realm in which to make changes will be taken from the krb5.conf configuration. Alternately, krb5-sync also supports processing actions from a file. To do this, use the -f flag and give the file on the command line. The format of the file should be as follows: <account> ad password | enable | disable <password> where the fourth line is present only if the <action> is "password". <account> should be the unqualified name of the account. The second line should be the string "ad" to push the change to Windows Active Directory. The third line should be one of "password", "enable", or "disable", corresponding to the -p, -e, and -d options respectively. The "enable" and "disable" actions are only supported for AD. The file format is not particularly forgiving. In particular, all of the keywords are case-sensitive and there must not be any whitespace at the beginning or end of the lines (except in the password, and only if that whitespace is part of the password), just a single newline terminating each line. When the -f option is given, the file will be deleted if the action was successful but left alone if the action failed. The configuration block in krb5.conf should look something like this: krb5-sync = { ad_keytab = /etc/krb5kdc/ad-keytab ad_principal = service/sync@WINDOWS.EXAMPLE.COM ad_realm = WINDOWS.EXAMPLE.COM ad_admin_server = dc1.windows.example.com ad_ldap_base = ou=People } If the configuration required for an action is not given, that action will not be performed but will apparently succeed from the perspective of the krb5-sync utility. Therefore, if this utility reports success but no change is happening, double-check the configuration to ensure that all required options are present. The "ad_keytab" option specifies the location of a keytab for authenticating to the other realm, the "ad_principal" option specifies the principal to authenticate as (using the key in the keytab), and the "ad_realm" option specifies the foreign realm. "ad_admin_server" is the host to contact via LDAP to push account status changes. "ad_ldap_base" specifies the base tree inside Active Directory where account information is stored. Omit the trailing "dc=" part; it will be added automatically from "ad_realm". OPTIONS
-d Disable the specified user in Active Directory. Requires that all of the ad_* options be set in krb5.conf. This option may not be specified at the same time as -e. -e Enable the specified user in Active Directory. Requires that all of the ad_* options be set in krb5.conf. This option may not be specified at the same time as -e. -f file Rather than perform a particular action based on a username given on the command line, read a queue file and take action based on it. The format of the queue file is described above. If the action fails, the file will be left alone. If the action succeeds, the file will be deleted. -p password Change the user's password to password in Active Directory. EXAMPLES
Disable the account "jdoe" in Active Directory (using the AD configuration found in krb5.conf): krb5-sync -d jdoe Change the password of the account "testuser" in Active Directory to "changeme": krb5-sync -p changeme testuser@EXAMPLE.COM The same, except also enable the account in Active Directory: krb5-sync -e -p changeme testuser Note that the realm for the user given on the command line is optional and ignored. Given a file named jdoe-ad-1168560492 containing: jdoe ad password changeme the command: krb5-sync -f jdoe-ad-1168560492 will change jdoe's password to "changeme" in Active Directory and then delete the file. SEE ALSO
The current version of this program is available from its web page at http://www.eyrie.org/~eagle/software/krb5-sync/ <http://www.eyrie.org/~eagle/software/krb5-sync/>. AUTHOR
Russ Allbery <rra@stanford.edu> 2.2 2012-01-10 KRB5-SYNC(8)