Wondering the best way to mass-import users

Get help from other users here.

Moderators: Developer, Contributor

mushu
Posts: 146
Joined: Jan 04, 2017 12:41 pm

Re: Wondering the best way to mass-import users

Post by mushu » Jan 24, 2019 3:56 pm

Mantis 2.18.0
Windows Server 2012 R2

cas
Posts: 690
Joined: Mar 11, 2006 11:08 am
Contact:

Re: Wondering the best way to mass-import users

Post by cas » Jan 24, 2019 4:02 pm

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: 146
Joined: Jan 04, 2017 12:41 pm

Re: Wondering the best way to mass-import users

Post by mushu » Jan 24, 2019 5:37 pm

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: 146
Joined: Jan 04, 2017 12:41 pm

Re: Wondering the best way to mass-import users

Post by mushu » Jan 30, 2019 5:01 pm

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: 690
Joined: Mar 11, 2006 11:08 am
Contact:

Re: Wondering the best way to mass-import users

Post by cas » Jan 31, 2019 7:23 am

setup mail to be send by cronjob and do not activate this. That can help :mrgreen:

mushu
Posts: 146
Joined: Jan 04, 2017 12:41 pm

Re: Wondering the best way to mass-import users

Post by mushu » Jan 31, 2019 11:38 am

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: 7690
Joined: Mar 26, 2008 4:37 pm
Location: Germany

Re: Wondering the best way to mass-import users

Post by atrol » Jan 31, 2019 11:49 am

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: 146
Joined: Jan 04, 2017 12:41 pm

Re: Wondering the best way to mass-import users

Post by mushu » Jan 31, 2019 11:53 am

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: 690
Joined: Mar 11, 2006 11:08 am
Contact:

Re: Wondering the best way to mass-import users

Post by cas » Feb 01, 2019 9:52 am

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 30 times

mushu
Posts: 146
Joined: Jan 04, 2017 12:41 pm

Re: Wondering the best way to mass-import users

Post by mushu » Feb 01, 2019 11:21 am

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: 690
Joined: Mar 11, 2006 11:08 am
Contact:

Re: Wondering the best way to mass-import users

Post by cas » Feb 01, 2019 12:01 pm

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: 690
Joined: Mar 11, 2006 11:08 am
Contact:

Re: Wondering the best way to mass-import users

Post by cas » Feb 02, 2019 4:39 am

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 28 times

mushu
Posts: 146
Joined: Jan 04, 2017 12:41 pm

Re: Wondering the best way to mass-import users

Post by mushu » Feb 04, 2019 2:18 pm

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: 690
Joined: Mar 11, 2006 11:08 am
Contact:

Re: Wondering the best way to mass-import users

Post by cas » Feb 04, 2019 3:13 pm

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 26 times

mushu
Posts: 146
Joined: Jan 04, 2017 12:41 pm

Re: Wondering the best way to mass-import users

Post by mushu » Feb 05, 2019 11:44 am

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