Forum Discussion
Marcel_Kuiper_5
Nimbostratus
Jun 22, 2007Adding 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
12 Replies
- Marcel_Kuiper_5
Nimbostratus
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";
} - Marcel_Kuiper_5
Nimbostratus
THNX Joe that did it! - Great! Please post again if anything else comes up.
-Joe - Daedulus69_1036
Nimbostratus
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 - Daedulus69_1036
Nimbostratus
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. - Daedulus69_1036
Nimbostratus
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. - Daedulus69_1036
Nimbostratus
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 - Daedulus69_1036
Nimbostratus
Thanks for the confirmation joe
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects