Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Check the NT login and email id with ADS

Posted on 2007-08-07
15
Medium Priority
?
327 Views
Last Modified: 2012-05-05
Hi,

I have a excel sheet and a txt file which has all the NT logins and Email id's of all users in the company.I dout that some are wrong.Is there a way to cross check these details with ads and list all data which is not found.

NT login    Email ID
Sharathr    sharath.reddy@plc.com

Regards
Sharath
0
Comment
Question by:bsharath
  • 7
  • 6
  • 2
15 Comments
 
LVL 16

Expert Comment

by:speshalyst
ID: 19645234
If you are familiar with LDAP queries, you could write one yourself to get a list of MAIL ENABLED users from the AD into an excel sheet.

Once you complete that, you can use the EXACT() funtion in excel to verify if they match..

0
 
LVL 16

Expert Comment

by:speshalyst
ID: 19645241
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 19648134
:: ===============
:: READ THIS FIRST
:: ===============
:: * This script MailIDs.txt file on C: drive root, from where it will pick users SAM ID of and email address.
::       'MailIDs.txt' file should be in following format (space separated):
::       <NTUserID> <Email Address>      
::      Like:
::       FKazi      fkazi@somedomain.com
:: * Successful run will generate "MailMismatch.txt" file on C: drive root.
:: * Copy and paste following script in notepad and save it with any name having .cmd extension.
::
:: *** SCRIPT START ***
@Echo Off
SETLOCAL EnableDelayedExpansion

IF NOT EXIST C:\MailIDs.txt Goto ShowErr
FOR %%R IN (C:\MailIDs.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\MailMismatch.txt DEL /F /Q C:\MailMismatch.txt

FOR /F "Tokens=1-2" %%i IN ('Type C:\MailIDs.txt') Do (
    Echo Processing: %%i
      SET Qry=DSQuery * DomainRoot -Filter "(&(objectCategory=Person)(objectClass=User)(sAMAccountName=%%i*))" -Attr Mail -L ^| Find "@"
      FOR /F "Tokens=1" %%x IN ('!Qry!') Do (
            IF /I NOT "%%j"=="%%x" Echo %%i: Email Mismatch >>C:\MailMismatch.txt
      )
)
Goto EndScript
:ShowErr
Echo 'MailIDs.txt' file does not exist or file is empty!
:EndScript
ENDLOCAL
:: *** SCRIPT END ***
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Author Comment

by:bsharath
ID: 19651299
Farhan i get this.

Processing: BramhaR
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
Processing: KumaresanV
The process cannot access the file because it is being used by another process.
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 19651393
I think there is something wrong with the system where you are running this script!
Restart the system and and then check. Also check this script on some other pc's.
0
 
LVL 11

Author Comment

by:bsharath
ID: 19651475
Ok farhan.

I tried in 5 machines and in one machine i got some thing different.

I got this in the results file.

HariKr: Email Mismatch
HariKr: Email Mismatch
HariKr: Email Mismatch
Jayal: Email Mismatch
Jayal: Email Mismatch
HariSh: Email Mismatch
HariSh: Email Mismatch
HariSh: Email Mismatch
HariSh: Email Mismatch
BalaSu: Email Mismatch
BalaSu: Email Mismatch
BalaSu: Email Mismatch
BalaSu: Email Mismatch
BalaSu: Email Mismatch
BalaSu: Email Mismatch
VijayaK: Email Mismatch
VijayaK: Email Mismatch
VijayaK: Email Mismatch
VijayaK: Email Mismatch
VijayaK: Email Mismatch
VinothK: Email Mismatch

Many names are duplicate and their email id's are correct.

How does this script check

Sharathr  Sharath.reddy@plc.com

Should there be onlt 1 space between the nt login and email id?
0
 
LVL 11

Author Comment

by:bsharath
ID: 19652302
I can remove the duplicates in the excel but
I get the results like this.

RajeshS       Email Mismatch
Rajeshse       Email Mismatch
RajeshV       Email Mismatch
RameshK       Email Mismatch
RameshS       Email Mismatch

But when i check the ads or my file the email id's are correct.
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 19652339
>> "Should there be onlt 1 space between the nt login and email id?" Correct

Above script will compare email address that you have given inside User Properties -> General -> E-mail in AD.

Kindly apply following commands and post the result.

Click Start -> Run -> Cmd.exe

DSQuery * DomainRoot -Filter "(&(objectCategory=Person)(objectClass=User)(sAMAccountName=HariKr))" -Attr Mail -L  | Find "@"

DSQuery * DomainRoot -Filter "(&(objectCategory=Person)(objectClass=User)(sAMAccountName=VijayaK))" -Attr Mail -L  | Find "@"
0
 
LVL 11

Author Comment

by:bsharath
ID: 19652461
I get this.

C:\>DSQuery * DomainRoot -Filter "(&(objectCategory=Person)(objectClass=User)(sA
MAccountName=HariKr))" -Attr Mail -L  | Find "@"
Hari.Krishna@plc.com

C:\>DSQuery * DomainRoot -Filter "(&(objectCategory=Person)(objectClass=User)(sA
MAccountName=VijayaK))" -Attr Mail -L  | Find "@"
Vijaya.Krishnamoorthy@plc.com
0
 
LVL 11

Author Comment

by:bsharath
ID: 19652690
I have tried with single space.
I only have this in the file
BramhaR Bramha.Reddy@plc.com
KumaresanV Kumaresan.Vaiyapuri@plc.com
SusantaK Susanta.Kumar@plc.com
SureshK Suresh.Kandan@plc.com
SivaP Siva.Prasad@plc.com
Thanak Thanasekar.Kasi@plc.com
Umag Uma.Maheswari@plc.com

I get this

BramhaR: Email Mismatch
KumaresanV: Email Mismatch
SusantaK: Email Mismatch
SureshK: Email Mismatch
SivaP: Email Mismatch
Thanak: Email Mismatch
Umag: Email Mismatch
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 19652735
Did you verified the email address inside User Properties -> General -> E-mail in ADS?
0
 
LVL 11

Author Comment

by:bsharath
ID: 19652777
Yes the email id's are there in user>properties> General > Email in ADS.
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 19653186
Run following script and post the results.

:: ===============
:: READ THIS FIRST
:: ===============
:: * This script MailIDs.txt file on C: drive root, from where it will pick users SAM ID of and email address.
::       'MailIDs.txt' file should be in following format (space separated):
::       <NTUserID> <Email Address>      
::      Like:
::       FKazi      fkazi@somedomain.com
:: * Successful run will generate "MailMismatch.txt" file on C: drive root.
:: * Copy and paste following script in notepad and save it with any name having .cmd extension.
::
:: *** SCRIPT START ***
@Echo Off
SETLOCAL EnableDelayedExpansion

IF NOT EXIST C:\MailIDs.txt Goto ShowErr
FOR %%R IN (C:\MailIDs.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\MailMismatch.txt DEL /F /Q C:\MailMismatch.txt

FOR /F "Tokens=1-2" %%i IN ('Type C:\MailIDs.txt') Do (
      SET Qry=DSQuery * -Filter "(&(objectCategory=Person)(objectClass=User)(sAMAccountName=%%i*))" -Attr Mail -L ^| Find "@"
      FOR /F "Tokens=1" %%x IN ('!Qry!') Do (Echo %%i : [%%j][%%x])
)
Goto EndScript
:ShowErr
Echo 'MailIDs.txt' file does not exist or file is empty!
:EndScript
ENDLOCAL
:: *** SCRIPT END ***
0
 
LVL 11

Author Comment

by:bsharath
ID: 19653260
I get this.

BramhaR : [Bramha.eddy@plc.com][Bramha.Reddy@plc.com]
KumaresanV : [Kumaresan.Vaiyapuri@plc.com][Kumaresan.Vaiyapuri@plc.com


No results file....
0
 
LVL 26

Accepted Solution

by:
Farhan Kazi earned 2000 total points
ID: 19653539
Try this:

:: ===============
:: READ THIS FIRST
:: ===============
:: * This script MailIDs.txt file on C: drive root, from where it will pick users SAM ID of and email address.
::       'MailIDs.txt' file should be in following format (space separated):
::       <NTUserID> <Email Address>      
::      Like:
::       FKazi      fkazi@somedomain.com
:: * Successful run will generate "MailMismatch.txt" file on C: drive root.
:: * Copy and paste following script in notepad and save it with any name having .cmd extension.
::
:: *** SCRIPT START ***
@Echo Off
SETLOCAL EnableDelayedExpansion

IF NOT EXIST C:\MailIDs.txt Goto ShowErr
FOR %%R IN (C:\MailIDs.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\MailMismatch.txt DEL /F /Q C:\MailMismatch.txt

FOR /F "Tokens=1-2" %%i IN ('Type C:\MailIDs.txt') Do (
    Echo Processing: %%i
      SET Qry=DSQuery * -Filter "(&(objectCategory=Person)(objectClass=User)(sAMAccountName=%%i*))" -Attr Mail -L ^| Find "@"
      FOR /F "Tokens=1" %%x IN ('!Qry!') Do (
         Echo %%j|Find /I "%%x" >NUL
       IF ErrorLevel 1 Echo %%i: Email Mismatch >>C:\MailMismatch.txt
      )
)
Goto EndScript
:ShowErr
Echo 'MailIDs.txt' file does not exist or file is empty!
:EndScript
ENDLOCAL
:: *** SCRIPT END ***
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
Know what services you can and cannot, should and should not combine on your server.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question