cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Set Things password from service

SOLVED
Level 1

Set Things password from service

Hi,

 

i have many Things with "Database" as Thing Template and i would like to make a service which sets the password to the database automatically (on running the service). 

i looked into the snippets and found nothing so i thought it might be a security policy.

 

is it possible? Thanks :)

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Set Things password from service

Hello,

 

Configuration section of a thing it's based on Configuration Tables, you should look on the services related to Configuration Tables in order to change any property shown on that section. Let's start:

 

  • GetConfigurationTables -->
    • ColumnAliases
    • ConnectionInfo
    • ConnectionMonitoring
  • From previous service we can infer that password will be on ConnectionInfo
  • GetConfigurationTable({ tableName: "ConnectionInfo"}) -> Infotable with the following columns
    • jDBCDriverClass, jDBCConnectionURL, connectionValidationString, MaxConnections, userName, password
  • Here we have the password value (but it's shown as ****), if you do it from a service you will see the real password (at least for TW 7.3.X )
  • Now you only need to Set the previous Configuration Table. the corresponding SetConfigurationTable or SetConfigurationTableRows in order to update the password accordingly.

Carles.

4 REPLIES 4

Re: Set Things password from service

Hello,

 

Configuration section of a thing it's based on Configuration Tables, you should look on the services related to Configuration Tables in order to change any property shown on that section. Let's start:

 

  • GetConfigurationTables -->
    • ColumnAliases
    • ConnectionInfo
    • ConnectionMonitoring
  • From previous service we can infer that password will be on ConnectionInfo
  • GetConfigurationTable({ tableName: "ConnectionInfo"}) -> Infotable with the following columns
    • jDBCDriverClass, jDBCConnectionURL, connectionValidationString, MaxConnections, userName, password
  • Here we have the password value (but it's shown as ****), if you do it from a service you will see the real password (at least for TW 7.3.X )
  • Now you only need to Set the previous Configuration Table. the corresponding SetConfigurationTable or SetConfigurationTableRows in order to update the password accordingly.

Carles.

Re: Set Things password from service

Hi Charles,

 

thanks for the answer! I tried as you said but i am facing a problem.

 

// result: INFOTABLE dataShape: "EntityList"
var result = me.GetConfigurationTables();

// table: INFOTABLE dataShape: ""
var table = me.GetConfigurationTable({
tableName: "ConnectionInfo" /* STRING */
});

me.SetConfigurationTableRows({
values: undefined /* INFOTABLE */,
persistent: undefined /* BOOLEAN */,
tableName: undefined /* STRING */
});

 

Here, at SetConfigurationTableRows, what am i supposed to fill? i cannot see the connection to the password i would like to change. Thank you!

Re: Set Things password from service

Something like this should do the trick:

 

 

var newPassword ="newDesiredPassword";
var databaseName = "yourDataBaseName";
var tableName = "ConnectionInfo";
var actual = Things["PersistenceProviderSystemDatabase"].GetConfigurationTable({ tableName: tableName });
actual.rows[0].password = Resources["EncryptionServices"].EncryptPropertyValue({ data: newPassword });
Things[databaseName].SetConfigurationTable({
    configurationTable: tableName,
    persistent: true,
    tableName: tableName
});

 

Re: Set Things password from service

Hi @gabitudor.

 

If one of the responses provided by @CarlesColl answered your question, please mark the appropriate one as the Accepted Solution for the benefit of others with the same question.

 

Regards.

 

--Sharon