Forum Discussion
bsdpruegelknabe
Nimbostratus
Nov 03, 2008create_user doesn't work or I'm to dumb?!
Hello,
the most possibillity is that I didn't understood to use create_user propperly...
Well, I hope anyone can help me here.
I use perl (yeah, I know, bite me... ;-p ) to create users on an F5 LB via Script.
My SOAP-Request looks like:
---
$soapResponse=$cu->create_user (SOAP::Data->name('users')->value(
'user' => {
'name' => $username,
'full_name' => $username'
},
'role' => $userrole,
'password' => '',
'home_directory' => '/home/'.$username,
'login_shell' => '/bin/false',
'user_id' => '0',
'group_id' => '500'
)
);
---
With the uri: 'urn:iControl:Management/UserManagement'
If I read on http://devcentral.f5.com/wiki/default.aspx/iControl/Management__UserManagement__create_user.html correctly - this should work. But doesn't. Can anyone give me an hint what I'm missing, please. :-)
TIA
bsdpruegelknabe
- Check out this thread in the forums where I posted a create_user perl script subroutine.
http://devcentral.f5.com/Default.aspx?tabid=53&forumid=1&postid=15013&view=topic
- bsdpruegelknabe
Nimbostratus
Posted By Joe on 11/03/2008 7:10 AM
- I just used the create_user API with a empty string as the passwd and this value was entered into /etc/shadow
joeuser:!!:14217:0:99999:7:::
- Here's the code I used
sub handle_create() { my ($UserName, $FullName, $Role, $Password) = @_; Some defaults for testing if ( $FullName eq "" ) { $FullName = "Fred Garvin"; } if ( $Role eq "" ) { $Role = USER_ROLE_ADMINISTRATOR; } if ( $Password eq "" ) { $Password = $UserName; } if ( $Password eq "" ) { $Password = ""; } $UserID = { name => $UserName, full_name => $FullName }; $UserInfo = { user => $UserID, role => $Role, password => $Password, home_directory => "/home/$UserName", login_shell => "/bin/bash", user_id => 0, group_id => 500 }; $soapResponse = $UserManagement->create_user( SOAP::Data->name(users => [$UserInfo]) ); }
- bsdpruegelknabe
Nimbostratus
Thats the code I use:my $host='hostnameoflb'; my %urls=( 'url' => "https://$host:443/iControl/iControlPortal.cgi", 'uri_usermgmt' => 'urn:iControl:Management/UserManagement', ); my @admins=("smurf", "gargamel", "azrael"); my $do=create_user( 'admins' => \@admins, ); sub create_user { my %config=@_; for (@{$config{'admins'}}) { my $pass=''; push @userdef, { 'user' => { 'name' => $_, 'full_name' => $_, }, 'role' => 'USER_ROLE_ADMINISTRATOR', 'password' => $pass, 'home_directory' => '/home/'.$_, 'login_shell' => '/bin/false', 'user_id' => '0', 'group_id' => '500', } } my $soap=soap_object('uri' => $urls{'uri_usermgmt'}); my $res=$soap->create_user(SOAP::Data->name('users' => [@userdef])); } sub soap_object { my %config=@_; my $soap=SOAP::Lite -> uri($config{'uri'}) -> proxy($urls{'url'}); eval { $soap->transport->http_request->header( 'Authorization' => 'Basic '.$enc_credentials ); }; return $soap; }
- I just ran your code and it created the following /etc/shadow entry on my device
smurf:!!:14223:0:99999:7:::
- bsdpruegelknabe
Nimbostratus
Ok. I will try to get a ticket out of this.
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