Adding users on 9.1.2

Hi,

Since we’re changing account names I need to create a lot of users on all of our BigIP systems. However my perl scripting is not succesful so far which has probably to do with the way I pass data to the call -- yes I’m clueless --. I try with this snippet of code:

$soap = SOAP::Lite

→ uri(‘urn:iControl:Management/UserManagement’)

→ readable(1)

→ proxy(“$sProtocol://$sHost:$sPort/iControl/iControlPortal.cgi”);

eval {

$soap->transport->http_request->header

(

‘Authorization’ =>

'Basic ’ . MIME::Base64::encode(“$sUID:$sPWD”, ‘’)

);

};

$user{‘name’} = “tester1”;

$user{‘full_name’} = “tester1 123”;

$UserInfo{‘user’} = $user;

$UserInfo{‘role’} = 0;

$UserInfo{‘password’} = “*LCK*”;

$UserInfo{‘home_directory’} = “/home/tester1”;

$UserInfo{‘login_shell’} = “/bin/bash”;

$UserInfo{‘user_id’} = 0;

$UserInfo{‘group_id’} = 500;

$users[$i++] = $UserInfo;

$soapResponse = $soap->create_user(

SOAP::Data->name(

‘users’ => @users

)

);

I can see in my logs that iControl receives the call. However no user is created. My tcpdump is not showing the XML i expected as well (no user name, etc)

Some helpful hints would be more then welcome

Cheers

Marcel

Ah, found some sample code on this forum, but I still can’t get it to work. Code now looks like:

$userid = {name => “tester1”, full_name => “Marcel Kuiper”};

@userinfo = (

{

user => $userid,

role => “USER_ROLE_ADMINISTRATOR”,

password => “*LCK*”,

home_directory => “/home/tester1”,

login_shell => “/bin/bash”,

user_id => 0,

group_id => 500

}

);

my $soapResponse = $soap->create_user(

SOAP::Data->name(users => [@userinfo])->type(“UserInfo[]”)

);

if ( $soapResponse->fault )

{

print $soapResponse->faultcode, " ", $soapResponse->faultstring, “\n”;

}

THNX Joe that did it!

Great! Please post again if anything else comes up.

-Joe

I am trying to do the same thing in powershell. I am able to following:

$ic = Get-F5.IControl

and invoke the method

$ic.ManagementUserManagement.create_user() but I need to pass in an object of type UserInfo

How do I create an object of this type?

Ahh, some fun PowerShell stuff!

For the methods that require typed structures, you need to create them with the “New-Object” Cmdlet. Here’s how you would make a call to create_user()

$ic = Get-F5.iControl
$userInfo = New-Object -TypeName iControl.ManagementUserManagementUserInfo
$userInfo.user = New-Object -TypeName iControl.ManagementUserManagementUserID
$userInfo.user.name = "testaccount"
$userInfo.user.full_name = "Joe User"
$userInfo.role = "USER_ROLE_ADMINISTRATOR"
$userInfo.password = "foobar"
$userInfo.home_directory = "/home/joeuser"
$userInfo.login_shell = "/bin/bash"
$userInfo.user_id = 0
$userInfo.group_id = 500
$ic.ManagementUserManagement.create_user( (,$userInfo) )

You’ll notice that the method takes an array, so the paramter is surounded by parenthesis and prefixed with a comma to indicate the creation of an array.

Hope this helps…

-Joe

Thanks Joe, that works great.

Another question how do I set the users console access? Users created with the above process have console access enabled, I don’t want that for our operators.

Sorry I guess I needed to be more clear. The $userinfo.role = USER_ROLE_TRAFFIC_MANAGER still grants Console access. ie I create this user and then go to the Web GUI and the user has console access enabled. I don’t really want to hack it and set the login_shell to something false.

I want to set the correct value so that if an admin in the GUI wanted to change it they would just have to uncheck the box.

Actually, From what I can tell, the The GUI just changes the login shell depending on what you have selected for Console Access

Disabled => /bin/false

Advanced Shell => /bin/bash

bigpipe Shell => /bin/bpsh

The following PowerShell code should work for setting the shell

$ic = Get-F5.iControl
$um = $ic.ManagementUserManagement
$um.set_login_shell( (,"joeuser"), (,"/bin/false") )

This should disable console access for user “joeuser”.

-Joe

Thanks for the confirmation joe

Quick question - what is the significance of “user_id” and “group_id” ? Is there documentation that I could search for quesitons like these as opposed to asking in the forums, so I don’t have to bug you guys?

Luke,

If you are unfamiliar with UNIX/Linux: user_id and group_id are UNIX-specific identifiers as the F5 host system is Linux-based, BUT, the please do read the note on create_user method in v10.1 SDK:

Note: this method is deprecated; please use create_user_3 and associated data. (home directory, user id, and group id are now computed by the system) Note: as of v10.1.0, this method will silently ignore any of user id, group id, and home directory passed in.

i.e. you don’t have to worry about user_id/group_id and home_directory anymore if you are running version 10.1+

Sam