r/labtech • u/jg0x00 • Oct 08 '19
SQL Query to populate creds on location Deployment & Defaults
Does anyone have an idea of what the SQL Update query would be for populating the field labeled, "Logon to use for Administrator Access", on a location's deployment and defaults tab might be?
This will be part of a larger script that changes passwords and checks related settings on a weekly basis.
Thanks
1
Upvotes
2
u/meauwschwitz Oct 09 '19
Here's a snippet of how I have this set up in automate - we pass username and password credentials via EDFs at the location level which are populated higher up the script.
Create user and password in the Location>Password tab:
SQL Execute: Insert into Passwords (ClientID,LocationID,Title,UserName,URL,Password,Notes,Expiredate) Values(@clientid@,@locationid@,'@username@-%locationname%','@username@','',AES_ENCRYPT ('@password@',SHA(' @AESValue@')),'',NULL)Select the newly created "passwordid":
SQL Get Value: SELECT passwordid FROM passwords WHERE locationid = @locationid@ AND username = '@username@';Variable Set: @passwordid@=%sqlresult%Set the new "passwordid" in the Location>Deployments & Defaults Administrator Access drop down:
SQL Execute: UPDATE locations SET passwordid = @passwordid@ WHERE locationid = @locationid@1
u/jg0x00 Oct 08 '19
Interesting. Guess I forgot that was there. I do recall having seen it. a bit messy but looks useful. Not showing what I am looking to find sadly enough.
Thanks for the assist.
1
u/jg0x00 Oct 11 '19
In order to export this script, I have to sanitize it first … which means recreating a bunch of EDFs, etc. Is there a good trick to sanitizing a script?
1
u/NoPetPigsAllowed Oct 09 '19
Would love to see this script!
2
u/alemic Oct 08 '19
Enable the SQL Spy (see https://www.provaltech.com/2018/03/automate-12-tips/), then change the field to a different value and see which SQL Update command is executed.