0

Hello All.

I want to update email in User table from the active directory. For this i am doing the following.
1. Extract all usernames from User table whose emails are not updated
SELECT username FROM `mantis_user_table` WHERE email = 'No Email' or email = '' into outfile "C:/temp/test1.txt"
2.Run command from command prompt to get the corresponding email ids from Active Directory with outputs username and email in text file
for /f %i in (test1.txt) do (dsquery user -samid %i|dsget user -empid -email|Find /V "dsget"|Find /V "empid"|Find /V "email">>C:/temp/user-email.txt)
3.Now i want to update these emails again in the User table. Can you please advice me how can i achieve step 3??

Many thanks.

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by iamthwee
0

Hmm, I think you need to tie each name to the email.

So I reckon the safest way would to write a massive query:

I'm just paraphrasing the syntax so it isn't 100% correct but you should get the idea.

UPDATE username = john dun ... email = email from text file
UPDATE username= sue smith... email = email from text file
.
.
.

If you know how to program you could probably code that to interrogate your text file and auto generate the query. Then simply paste that query into your MySql prompt.

(Disclaimer: This is just a suggestion and hasn't been tested, use at your own risk)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.