Gcp appengine app does not correctly connect to Cloud sql database - sql-server

I have connection issue between my spring boot/kotlin app and database. I tried following guides what google has to offer and some Stackoverflow posts. I added client/admin sql permisions to users.
After following google guide https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-samples/spring-cloud-gcp-sql-postgres-sample on this link and recreating everything as it is. I came to problem: deployed App does not connect to actual database, instead it uses data.sql and schema.sql objects from resources, also it does not do changes to actual database, but somewhere else, for example I am using this command to getdata:
#GetMapping("/getdata")
fun getTuples(): List<String>? {
return jdbcTemplate!!.queryForList("SELECT * FROM users").stream()
.map { m: Map<String?, Any?> -> m.values.toString() }
.collect(Collectors.toList())
}
result I get is the one provided in example:
0 "[luisao#example.com, Anderson, Silva]"
1 "[jonas#example.com, Jonas, Goncalves]"
2 "[fejsa#example.com, Ljubomir, Fejsa]"
the actual users table in Cloud database looks like this:
postgres=> select * from users;
email | first_name | last_name
--------------------+------------+-----------
luisao#example.com | Anderson | Silva
jonas#example.com | Jonas | Goncalves
fejsa#example.com | Ljubomir | Fejsa
kkskldk | sjndjfdf | skdskd
(4 rows)
first 3 rows are same just because I added them manually. App does not see DDL/DML changes in database, only those I do in data.sql or schema.sql. So the question is where could be a problem?
in this documentation https://cloud.spring.io/spring-cloud-gcp/multi/multi__spring_jdbc.html says that this dependency should do most of the stuff automaticly but somehow something goes wrong.
Could it be that spring boot/hikari creates virtual enviroment in appengine which blocks database connection and you connect and see only Mock data from data.sql files? Or problem lies in configuration?
My application.properties file:
server.error.include-message=always
spring.cloud.gcp.sql.database-name=[database name]
spring.cloud.gcp.sql.instance-connection-name=[Instance name]
spring.datasource.continue-on-error=true
spring.datasource.initialization-mode=always
spring.datasource.username=postgres
spring.datasource.password=[password]
spring.cloud.gcp.project-id=[project id]

Related

Azure AD extraction script

Me (and the company I work for) are looking for a script to extract the following information from an AzureAD.
Accountname
Username
Description
creation date
last login
Blocked yes or no
Date last password change
Password expiration date
Administrator yes or no
Futhermore:
NTFS groups
Computer SID (OS and version / assigned to which OU / Last time seen online)
And lastly
Password policy
We require our customers to provide this information when they are subject to a financial audit. Currently we have a working extraction script which give a .csv export which we can import in a qlikview dashboard. With this dashboard we can look for possible security risks. We do not export passwords and do not want passwords of accounts.
I have been looking for such a script for a couple of weeks but can't seem to find one that gives us this result.
I hope someone can help.
This is not a good question, but since I needed almost the same information, I will show you how you can start solving your issue, and for others ending up in this question by searching.
Start by installing this https://www.powershellgallery.com/packages/AzureAD/2.0.2.4 to your powershell
Then you connect to your Azure AD.
$_adroles = #()
$_docpath = $env:userprofile + '\Documents\ADDirRole.csv'
Get-AzureADDirectoryRole | foreach {
$_objectid = $_.ObjectId; $rolename = $_.Displayname
$_adroles += Get-AzureADDirectoryRoleMember -ObjectId $_objectid | select `
#{name='RoleName';expression={$rolename}},displayname,UserPrincipalName,UserType,LastDirSyncTime,DirSyncEnabled,mail,accountenabled
}
$_adroles | export-csv $_docpath –NoTypeInformation
For more information see: https://blogs.technet.microsoft.com/chadcox/2017/06/30/powershell-useful-azure-ad-queries-using-the-azuread-module/
And the documentation is here: https://learn.microsoft.com/en-us/powershell/module/azuread/?view=azureadps-2.0#users

OrientDb - Select from multiple vertices using graph

I am just starting out with nosql databases, and OrientDB in particular. My prior experience is with relational databases, mostly with SQL Server.
In MSSQL, I can do something like this:
SELECT s.url, p.title
FROM Site s
JOIN Page p ON s.Id = p.SiteId
And it will give me a table of all pages, along with the url of the site they belong to:
url | title
----------------------------
site1.com | page1
site1.com | page2
site2.com | page1
Now, in OrientDb, my understanding is that you should use a link for a one-way relationship, or an edge for a bidirectional relationship. Since I want to know what pages belong to a site, as well as what site a particular page belongs to, I have decided to use an edge in this case. The Site and Page classes/vertices are already created in similar fashion, but I can't figure out how to get a similar result set. From the documentation (https://orientdb.com/docs/2.2/SQL.html):
OrientDB allows only one class (classes are equivalent to tables in
this discussion) as opposed to SQL, which allows for many tables as
the target. If you want to select from 2 classes, you have to execute
2 sub queries and join them with the UNIONALL function
Their example SELECT FROM E, V then becomes SELECT EXPAND( $c ) LET $a = ( SELECT FROM E ), $b = ( SELECT FROM V ), $c = UNIONALL( $a, $b ), but that's not what I want. That results in something along the lines of
url | title
----------------------------
site1.com |
site1.com |
site2.com |
| page1
| page2
| page1
How would I go about creating the original result set, like in MSSQL?
Additional consideration: My training and experience with MSSQL dictates that database operations should be done in the database, rather than the application code. For example, I could have done one database call to get the s.url and s.id fields, then a second call to get the p.title and p.SiteId fields, and then matched them up in application code. The reason I avoid this is because multiple database calls is less efficient time-wise than the time it takes to return the extra/redundant information (in my example, site1.com is returned twice).
Is this perhaps not the case for OrientDb, or even graph/nosql databases in general? Should I instead be making two separate calls to get all of the data I need, i.e. SELECT FROM Site WHERE Url = "site1.com" AND SELECT EXPAND(OUT("HasPages")) FROM Site WHERE Name = "site1.com"?
Thank you
Try this:
select Url, out("HasPages").title as title from Site unwind title
Hope it helps
Regards

AWS SimpleDB contains value

I am trying to make a db query (AWS simpleDB) and want only things to return if they contain the # symbol somewhere in the email field. I am starting like this
select * from `myDomain` where email = _____
I just can't figure out what to put in that space.
I found this article which explains features and keywords of simpleDB but was unable to see anything here that could help me... http://aws.amazon.com/articles/1231
So if there are 3 items with emails 1."abc#def.com" 2. "1234" 3."asdf" then only "abc#def.com" should be returned because it contains #.
select * from myDomain where email like '%#%'
Source:
http://aws.amazon.com/articles/1231

Trouble Uploading Person Accounts Into Salesforce Using Apex Data Loader

I am trying to import ~15k PersonAccounts into Salesforce using the Apex Data Loader version 25.0.1 available here.
I have already called Salesforce and enabled PersonAccounts on my Organizaion. I have successfully logged in with my admin credentials and exported a RecordType csv showing the following info:
ID | NAME | DEVELOPERNAME
01280000000Lsy4AAC | Person Account | PersonAccount
01280000000LsxzAAC | Business Account | Business_Account
I have created a new csv with the following columns:
RECORDTYPEID
LASTNAME
FIRSTNAME
DESCRIPTION
PERSONMAILINGSTREET
PERSONMAILINGCITY
PERSONMAILINGSTATE
PERSONMAILINGPOSTALCODE
PERSONMAILINGCOUNTRY
PERSONHOMEPHONE
PERSONEMAIL
and specified 01280000000Lsy4AAC for all records in the RECORDTYPEID column.
When I attempt to insert my csv I get the same error for all rows:
Record Type ID: id value not valid for the users profile: 01280000000Lsy4AAC
What am I doing wrong? How do I upload PersonAccounts using the Apex Data Loader?
Update: I have tried the method recommended here of getting the RecordTypeID from the query string of the web interface (which gives you the same RecordTypeID without the "ACC" suffix and I still get the exact same error.
I had to enable Person Accounts on my Sys Admin profile
Setup -> Manage Users -> Profiles -> System Administrator, then Object Settings, then Account, and make sure Person record type is assigned.
https://sites.secure.force.com/success/questionDetail?qid=a1X30000000duV6EAI

How to know the GUID of a Database?

I follow this step by step http://technet.microsoft.com/en-us/library/ff681014.aspx for reset the User Profile Synchronization Service but I need the GUID of the synchronization database.
I searched a lot but I didn't find anything. I need also to find the GUID of the/a service.
Thank you
You can use Powershell to do this the way MS describes in the Technet article or the smart way:
$syncDBType = "Microsoft.Office.Server.Administration.SynchronizationDatabase"
$upaSAType = "User Profile Service Application"
$syncDB = Get-SPDatabase | where-object {$_.Type -eq $syncDBType}
$upa = Get-SPServiceApplication | where-object {$_.TypeName -eq $upaSAType}
$syncDB.Unprovision()
$syncDB.Status = "Offline"
$upa.ResetSynchronizationMachine()
$upa.ResetSynchronizationDatabase()
$syncDB.Provision()
restart-service SPTimerV4
So we actually don't look for the guid but look where the database type is the sync database type. You can find more troubleshooting gems like this on Harbars site: “Stuck on Starting”: Common Issues with SharePoint Server 2010 User Profile Synchronization

Resources