Visit Our UNIX and Linux User Community


Shell Script for generating NTIDs(Usernames) from the email ids which exists in MSAD Directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script for generating NTIDs(Usernames) from the email ids which exists in MSAD Directory
# 1  
Old 06-19-2013
HP Shell Script for generating NTIDs(Usernames) from the given email ids.

Hi Everyone,

I just need a shell script which automatically gives the list of NT IDs mean the Usernames from the list of email ids. We have around 140 users from AMERICAS,ASIAPACIFIC and EMEA User Directories and we have their email ids.For ex. i have email id called naveen-kumar.dasu@hp.com and this user NT ID is dasun.So i need dasun as output for this email id. So the script by taking their email ids or by connecting to User Directory the script needs to give the output of all the list of NT IDs from these directories. All the User Directories exists with MSAD Configured. Any ones help is highly appreciated.

Regards,
Naveen

Last edited by naveen.dasu; 06-19-2013 at 07:47 AM..
# 2  
Old 06-19-2013
It sounds like something an Excel macro could do, and just save it as text to drive your user add script. Sun has ldapsearch, so what OS are we dealing with?
# 3  
Old 06-19-2013
this is quiet simple but you are going to run into problems with people using same or similar names if you do not put in enough checks ... funky sample below will create NTID "thereh" twice ...
Code:
susegeek:/tmp # for email in hola.there@hp.com hello.there@hp.com como.esta@hp.com
> do
>     lname=$(echo $email | awk -F"[.@]" '{print $2}')
>     finitial=$(echo $email | awk -F"[.@]" '{print $1}' | awk '{split ($0,a,""); print a[1]}')
>     ntid=$lname$finitial
>     echo "$email = NTID = $ntid"
> done
hola.there@hp.com = NTID = thereh
hello.there@hp.com = NTID = thereh
como.esta@hp.com = NTID = estac
susegeek:/tmp #

# 4  
Old 06-20-2013
Hi,
Many Thanks for your reply we use windows 7 OS and if i can get this with excel macro that is very much good.Can you help me how can we do this using Excel Macro.


Regards,
Naveen

---------- Post updated at 08:12 AM ---------- Previous update was at 08:07 AM ----------

Hello Just Ice,

Thanks for your reply. Actually i do have the list of the people and their name are unique and there are 140 users. So how could i give these as input for this script.I exported the users to excel.

Regards,
Naveen
# 5  
Old 06-20-2013
export the email column from excel into a .txt file on a directory on the unix server and use that file as the input file ...

input file:
Code:
hola.there@hp.com
hello.there@hp.com
como.esta@hp.com

sample script:
Code:
#! /bin/ksh
list=$1

if [ $# -ne 1 ]
then
      echo "Not enough arguments. Please rerun script with \"$0 \$listfile\""
      exit 1
else
      if [ ! -s $list ]
      then 
          echo "No valid list file found. Rerun script with readable text file."
          exit 2
      fi
fi

for email in $(< $list)
do
     lname=$(echo $email | awk -F"[.@]" '{print $2}')
     finitial=$(echo $email | awk -F"[.@]" '{print $1}' | awk '{split ($0,a,""); print a[1]}')
     ntid=$lname$finitial
     echo "$email = NTID = $ntid"
done

exit 0

# 6  
Old 06-20-2013
Hello Just Ice,

Thanks Again. Actually the NT IDs differ from email to email. I mean all are not like Lastname and Firstnames first initial.Like for Naveen Kumar Dasu its like dasun.Its not same for all the email ids. So basically we have a LDAP Directory.So we need to connect to the LDAP directory and retrive the NT IDs for the 3 User Directories AMERICAS,ASIAPACIFIC and EMEA. I just want a script which connects to LDAP Directory and gets the NT IDs.

Help on this is highly appreciated.

Regards,
Naveen
# 7  
Old 06-20-2013
This User Gave Thanks to DGPickett For This Post:

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Send an email if "No such file or directory" in the shell script program log in EBS concur

Hi All, I have the below code(.sh) and need to send an email. #!/bin/bash cp /u02/xxc_incoming/TEST*.dat /u02/xxc_archive_incoming/AMER7764_ARPP_2/ cat /u02/xxc_incoming/TEST*.dat > /u02/xxc_incoming/XXC_TEST.dat rm /u02/xxc_incoming/TEST*.dat cd $XXC_TOP/bin sqlldr userid=apps/<pwd> ... (12 Replies)
Discussion started by: Mist123
12 Replies

2. Emergency UNIX and Linux Support

Email ids from gecos

I would like to extract only the email ids from the gecos of each user id. I have to get the email ids of all the users on the server like this. Can someone please assist me with the command/script? (15 Replies)
Discussion started by: ggayathri
15 Replies

3. Shell Programming and Scripting

script to tell whether there exists directory or not

Hi, I am writing a script as follows: #!/bin/sh set -x for i in `cat a`; do #sleep 3 print $i >> server.txt sleep 5 if test -d `vtask $i "' ls -lrt /opt/log/ '" ` ; then print $i >> 12.5.txt else print $i >> 12.0.txt fi done (7 Replies)
Discussion started by: dbashyam
7 Replies

4. Shell Programming and Scripting

Problem with script generating files in directory recursively

I have a script which generates recursively some files in folders for a given root folder. I have checks for permissions and it works for all folders except one(i have 777 permission on it). When i try calling the script in problematic folder(problematic folder being root folder), script works as... (2 Replies)
Discussion started by: bb2
2 Replies

5. Shell Programming and Scripting

Send Email to group ids

hi, I want to send mail to DL... i am sending email to single id using mailx .. how to send to group of ids? :confused: i am using a file which conatins all the ids, is there any other way to send mail without creating the DLfile? DL=path\file.txt mailx -s "Info BG is now... (4 Replies)
Discussion started by: sreelu
4 Replies

6. Shell Programming and Scripting

Shell script: If a file stays in a particular directory more than 30 min send an email

Hi , I am new to shell scripting. i have a requirement say i will receive a file in a directory say /xyz.if that file stays in that directory more than 30 min i need to get a mail to my outlook.this should run for every 20 min in crontab. can anyone help me? (8 Replies)
Discussion started by: muraliinfy04
8 Replies

7. UNIX for Dummies Questions & Answers

A shell script or software for generating random passwords

Hi, Is there an shell script/batch file to genarate random passwords which expires after a stipulated time period? Please suggest a software which does this for AIX and windows both else. Thanks. (5 Replies)
Discussion started by: dwiravi
5 Replies

8. HP-UX

Sending email to multiple IDs

Hi, I am trying to send an email to multiple IDs from Unix script. I have given the EmailIds in a file and trying to use the file as input in the script. > cat Email EmailID = "abc@xyz.com cbz@xyz.com" In my script I have . /Email mailx -s "subj" $EmailID This fails with the... (3 Replies)
Discussion started by: sangharsh
3 Replies

9. Shell Programming and Scripting

Generating millions of record using shell script

Hi All, My requirement is like this. I want to generate records of 1 million lines. If I say lines it means one line will contain some string or numbers like AA,3,4,45,+223424234,Tets,Ghdj,+33434,345453434,........................ upto length lets say 41. ( 41 comma sepearted aplha numneric... (2 Replies)
Discussion started by: Rahil2k9
2 Replies

10. Shell Programming and Scripting

shell script to send email with usage of space in the directory as description :

shell script to send email with usage of space in the directory as description : Please any one help me in writing a script to send email with usage of space in the directory as description . (3 Replies)
Discussion started by: sakthifire
3 Replies

Featured Tech Videos