Wondering the best way to mass-import users

Get help from other users here.

Moderators: Developer, Contributor

mushu
Posts: 349
Joined: 04 Jan 2017, 17:41

Re: Wondering the best way to mass-import users

Post by mushu »

Mantis 2.18.0
Windows Server 2012 R2
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Wondering the best way to mass-import users

Post by cas »

I only had errors eing reported hence I missed the notifcactions. Same time the import worked fine.
Is the import now running ok on your end?
mushu
Posts: 349
Joined: 04 Jan 2017, 17:41

Re: Wondering the best way to mass-import users

Post by mushu »

I will need some time to test it because I need to write the code to grab the employee data from active directory and stuff it into a csv flat file. but I can at least manually edit the sample csv file you supplied to test it I guess...will let you know.
mushu
Posts: 349
Joined: 04 Jan 2017, 17:41

Re: Wondering the best way to mass-import users

Post by mushu »

So I finally had time to code up a script to grab all users from our active directory forest and stuff it into a csv file in the proper format. I ran the latest version of your plugin and it seemed to work perfectly, skipping accounts that already exist. Yay! Thank you so much for this. Plus, it gives me a template to follow for when I begin to write new plugins. :-)

Only thing is, it sent an account creation notice to 1000+ users (oops) since I forgot that Mantis sends an email when an account is created. Plus, I ran this on DEV so I will need to run it on Production next, but figure out how to disable account cration emails--I hope it's just a global variable I can set in the config file...
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Wondering the best way to mass-import users

Post by cas »

setup mail to be send by cronjob and do not activate this. That can help :mrgreen:
mushu
Posts: 349
Joined: 04 Jan 2017, 17:41

Re: Wondering the best way to mass-import users

Post by mushu »

Well, this is on the Production site so I can't change how email is processed by Mantis. I will have to find a variable that prevents Mantis from sending out ANY emails, then import the users, then turn that variable back off so Mantis can continue to process emails. i hope it works, I already spammed 1000+ people without prior warning, don't want to do that again!
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Wondering the best way to mass-import users

Post by atrol »

There is option $g_enable_email_notification http://mantisbt.org/docs/master/en-US/A ... nfig.email
Please use Search before posting and read the Manual
mushu
Posts: 349
Joined: 04 Jan 2017, 17:41

Re: Wondering the best way to mass-import users

Post by mushu »

Thanks for that. Unfortunately, I wanted it so it would not send the user an email notice that an account was created for them, and the variable you listed says it won't handle that.

So now my quest is to figure out how to create accounts without Mantis sending the customer an email. :-(
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Wondering the best way to mass-import users

Post by cas »

The best way is to adjust the plugin :D
Check out version 1.02 , now with an indicator in column 5 to send an email or not (1=send, 0= do not send).
Attachments
import_user102.zip
(4.72 KiB) Downloaded 373 times
mushu
Posts: 349
Joined: 04 Jan 2017, 17:41

Re: Wondering the best way to mass-import users

Post by mushu »

Thank you for the update! Before I run this, how does it actually prevent Mantis from sending a new-user-account email? I thought that was hard-coded in Mantis to always send an email when a new account is created...and no global variable exists to prevent it? I was going to just put in a fake SMTP server in config prior to running the plugin to ensure that no emails can be sent. I got pounded for the company-wide spam last time and don't want to get in trouble again. :-(
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Wondering the best way to mass-import users

Post by cas »

I created a copy of the default Mantis routine which would send out the email if a mail address existed. Now it checks the parameter from the inputfile expecting a valid email address in case you want to send an email.
For that check I will build one more check but for your activity this would be ok.
Please have a go and make a small test :mrgreen:
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Wondering the best way to mass-import users

Post by cas »

I have improved the chcek for sending emails ( or not) and adjusted the readme.
So have fun with version 1.03 :mrgreen:
Attachments
import_user103.zip
(4.76 KiB) Downloaded 323 times
mushu
Posts: 349
Joined: 04 Jan 2017, 17:41

Re: Wondering the best way to mass-import users

Post by mushu »

New version still did not declare variable in the _page.php file so I added it at the top like before, yet it crashes when I try to import the sample.csv file now. I get a server error 500. :-(
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Wondering the best way to mass-import users

Post by cas »

fixed both things in version 1.04.
Newer versions will be available via Github.
Currently on to 1.05 :mrgreen:
Attachments
import_user104.zip
(4.76 KiB) Downloaded 364 times
mushu
Posts: 349
Joined: 04 Jan 2017, 17:41

Re: Wondering the best way to mass-import users

Post by mushu »

Thank you for all your hard work, I just ran it and it imported the users without sending emails. Yay!

However, now Mantis won't process *any* emails. So I'm wondering what process you used to prevent sending emails, and if this would have interfered with the EmailReporting plugin in any way? I've uninstalled the import_users plugin but it still doesn't seem to process emails from the inbox. Thoughts?
Post Reply