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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Set Things password from service

gabitudor
10-Marble

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 :)

ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

4 REPLIES 4

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.

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!

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
});

 

slangley
23-Emerald II
(To:CarlesColl)

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

Announcements


Top Tags