Article Options
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Importing users into NetMRI via the API
Here's a perl script that shows how you can use the API to import users into NetMRI
use strict; use warnings; use NetMRI::API; # Comment this out if you are using HTTPS $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0; # get the device id from the command# line as the first argument. # Connect to the NetMRI. my $client = new NetMRI::API({ api_version => '2.8', }); ################################## #The "users_list.data" files needs to be in the following format #username,password,email,firstname,lastname ################################# #open (READ_USERS, 'users_list.data'); ################################## #Now we will read through each line in the file and assign them to variables ################################## my $broker = $client->broker->auth_user; while ( my $ask=){ my @list = split(/,/, $ask); my $list_username = $list[0]; my $list_password = $list[1]; my $list_email = $list[2]; my $firstname = $list[3]; my $lastname = $list[4]; $broker-> create(email =>list_email,first_name => $firstname,last_name => $lastname,password_secure => $list_password,user_name => $list_username); }
Comments