6 Replies Latest reply on Feb 14, 2017 9:25 AM by llarochelle

    Updating account password through API ?

    llarochelle

      I've been looking at the db structure. According to the Accounts table, there are 2 columns related to the password : "password" and "password-hash"

       

      Question : Is the password purely managed by SQL ? if so, how can it be updated ?

       

      Otherwise, does the SWIS API can manage account passwords ?

       

      I've been looking for a way for users to update their password on Orion, but no luck.


      Best regards,

       

       

      Luc

        • Re: Updating account password through API ?
          derhally

          If you have Orion NPM 12.0 or Orion Platform 2016.2.100 then you should have the following verbs available to you on the "Orion.Accounts" entity

           

          CreateOrionAccount which takes arguments  accountId and password

           

          and

           

          ChangePassword which takes arguments accountId and password

           

          you will need admin rights on the server to call those verbs.

          1 of 1 people found this helpful
            • Re: Updating account password through API ?
              llarochelle

              Hi derhally,

               

              Thank you for the reply. I'm not sure about the verbs ? I've been using the API using queries such as these two lines (preceding code defines the connection to the server

               

              # build query string

              my $query = sprintf("SELECT Caption, IPAddress FROM Orion.Nodes n WHERE n.CustomProperties.xxxx = 'yyyy'");

              my $response = $client->GET('/SolarWinds/InformationService/v3/Json/Query?query=' . uri_encode($query));

               

              Or through the module : Net::SolarWinds::REST.

               

              I'm not so familiar with verbs. If you could provide an example of how you use it, it would help a lot.

               

              Best regards,

                • Re: Updating account password through API ?
                  tomas.vrabel

                  Example below shows how to call ChangePassword verb. I tested it for NPM 12.0.1 and works fine.

                   

                  #!/usr/bin/perl

                  use strict;

                  use warnings;

                  use REST::Client;

                  use MIME::Base64;

                  use URI::Encode qw(uri_encode);

                  use JSON::Parse ':all';

                  use JSON;

                   

                  ################################################################################

                  # Configuration

                  ################################################################################

                   

                  my $username = 'domain\username';  # user/pass works too for local SW accounts

                  my $password = 'password_here';

                  my $hostname = 'your_hostname';

                   

                  ################################################################################

                  # Execution

                  ################################################################################

                   

                  my $client = REST::Client->new();

                   

                   

                  # don't verify SSL certs                                                                                                       

                  $client->getUseragent()->ssl_opts(verify_hostname => 0);                                                                       

                  $client->getUseragent()->ssl_opts(SSL_verify_mode => 'SSL_VERIFY_NONE');

                   

                  # add authentication header

                  $client->setHost('https://' . $hostname . ':17778');

                  $client->addHeader('Authorization', 'Basic ' . encode_base64("$username:$password", ''));

                   

                  # set account login and new password

                  my $accountId = 'account_login';  # e.g. guest

                  my $pwd = 'new_password';

                   

                  #invoke verb

                  my @params = ($accountId , $pwd);

                  my $verbResponse = $client->POST('/SolarWinds/InformationService/v3/Json/Invoke/Orion.Accounts/ChangePassword',

                    encode_json(\@params),

                                 {'Content-Type' => 'application/json',

                                  'Accept' => 'application/json'});

                   

                  print 'Response: ' . $client->responseContent() . "\n";

                  print 'Response status: ' . $client->responseCode() . "\n";

                  1 of 1 people found this helpful