Issue of type password field in datashape making problem On import
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Issue of type password field in datashape making problem On import
Hello Community,
I have datatable with usercredentials stored in it and one of the field is of password type which i do hash also before saving it. Now the issue is when i import this datatable from thingworx 9.1 to 9.3 and in my code below:= i am unable to get the value from datatable it just does not appear EntryExists.row[0].loginPassword is undefined even though on old thingworx version everything is working fine.
let EntryExists = Things[userDataTable].GetDataTableEntryByKey({ key: hashedLoginName });
if(EntryExists && EntryExists.rows[0].hashedLoginName == hashedLoginName && EntryExists.rows[0].loginPassword == hashedLoginPassword){
I have changed nothing but still it just does not work because its not getting it from datatable but on other hand all the fields are showing values. Why its like that
My assumption: I think its not possible to import the userpassword which are hashed into another datatable and if i change the password field to string and then import the datatable still it shows the different hashed values and my service does not work on new server.....
- Labels:
-
Best Practices
-
Coding
-
Examples
-
Troubleshooting
- Tags:
- thingworx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Have you tried Universal Export, with Binary or XML, for entities not data?
Javed Akhtar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
how can i export a datatable with binary or XML any idea? Its a datatable actually and i can only import it as data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I mean while exporting data table entity select universal export, and Export data as usual.
Also make sure whatever hashing key (mechanism I am guessing) you are using that is already present on target server.
Javed Akhtar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
this is the error on import which is coming
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Please use file storage to export the data, then copy that data in file storage of target server, and import using Source Control Entities (or File storage). Refer the documentation below:
Importing and Exporting Data, Entities, and Extensions (ptc.com)
Javed Akhtar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
oh i have choosen import type entity and now import is done but now i cannot see any data entries in this datatable. should i do now import for data ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
There are two steps.
1. Export data table entity, it will have only structure/definition but not data.
2. To export data, you need to export it separately as said above.
Javed Akhtar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
i have followed these both steps still not working should i try now with xml?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Please follow below steps to export and import data (Provided data table entity is already there), make sure required folder are there inside repository
Javed Akhtar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
thanks for your info but still the field loginPAssword is empty it just does not take the value of this field in datatable all the entries have no value for this field because it is of type password may be thats why.
if i change it to string and do then import then the values come but then my system still does not work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Once value is there in system as a string, you might write service to hash again and update the values.
Javed Akhtar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Also please check article below this is relevant to your case:
Javed Akhtar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
So, here it is a way.. I am doing ..first hashing of the password and secondly the baseType of field password is also password so it get again somehow hashed from the system. As per documentation they recommended to do like this ===> Resources["EncryptionServices"].EncryptPropertyValue(params)
I dont think so that there is any way to import these passwords then from datatable.
result.AddRow({
loginName: loginName.toUpperCase(),
firstName: firstName,
lastName: lastName,
language: language,
emailAddress: emailAddress.toLowerCase(),
hashedLoginName: me.SHA256({
toHash: loginName.toUpperCase()
}),
groups: groups,
loginPassword: Resources["EncryptionServices"].EncryptPropertyValue({
data: me.SHA256({
toHash: loginPassword
})
})
});
//me.UserDataBase
Things[userDataTable].AddDataTableEntry({ values: result });
info: There is a difference between hashing and encryption. SHA256 is a hashing function not an encryption function.
Since SHA256 is not an encryption function, it cannot be decrypted. What you probably want is reversing hashed value to normal text.
SHA256 cannot be reversed because it’s a one-way function it is not designed to be used that way
that’s the idea behind hashing - so that if somebody has your data they cannot “read it”.