How can a SharePoint SQL connection be set to query by the current login name? - sharepoint

I have a SQL table that needs to be queried by the login name. So, using SharePoint designer I successfully created a database connection, but I can't use the properties exposed by Profile nor Session as input parameters because they are not supported (A dialog pops up with a message indicating this)
How else can I query a SQL datasource by using the current login?
-Edit
To create the data connection, proceed as follows
Open the data source library
Expand database connections and click on connect to a database
Enter the database settings
Select "specify custom Select, Update, Insert, and Delete"
Click on Edit Command
Add a parameter and select Profile and enter UserName as the property name
An error will follow stating that this is not supported.

Unfortunately, you don't give many details but I think you're looking for the LOGON_USER Server Variable: Data View / Data Form: Parameters You Don’t Know About.

Related

Using Oracle.Database M language function in Power BI Desktop

I am writing a custom connector for Power BI Desktop. The custom connector would simply connect to Oracle DB and fetch some data.
For this, I am trying to use Oracle.Database data source function which is defined as below:
Oracle.Database(server as text, optional options as nullable record) as table
Clearly there is no option to pass the DB credentials in the above function.
Questions:
Do we not need to pass DB credentials to this function?
From where this function pick the DB credentials?
Would it be picking up the credentials from Extension.CurrentCredential() function?
Secondly, I have enabled "UsernamePassword" kind of authentication in my connector so when I try to use the connector, it prompts me to supply the username and password. After typing in the username and password, when I click "Connect" button then it simply shows the message "Please specify how to connect". Any ideas why it is showing this message when I have just provided the credentials on the dialog box?

Using Excel as the front end, Azure as the backend

I have a SQL Database on Azure to which I can successfully get connected from within an Excel file. I am using ADO and the connection string uses my own username and password. Since this file will be used by many users, how can I create a generic login and password so that I would not give out my own username and password in the code? The Excel file runs many VBA macros to communicate with the Azure SQL database.
I am using Excel 2010 (yeah, it is old, I have to) and this is my connection string:
mstrConnectionString = "Driver={SQL Server Native Client 11.0};" & _
"Server=tcp:<servername>.database.windows.net,1433;" & _
"Database=<databasename>;" & _
"Uid=<myusername>#<servername>;" & _
"Pwd={MyPassword};" & _
"Encrypt=yes;Connection Timeout=30;"
According your comment, I have an idea that you can create a new login/user for you Azure SQL database.
Then you use this user and password as public account to get or writer data from your Azure SQL database within Excel.
Here's the example T-SQL statement, this code is create a new login and a user in your Azure SQL database. You can run this query in SSMS:
--running in master db
USE [master]
GO
CREATE LOGIN [sagarreadonly] WITH PASSWORD='password'
GO
-- running in Azure SQL DB
USE [DataEncryptDemo]
GO
CREATE USER [sagarreadonly] FOR LOGIN [sagarreadonly] WITH DEFAULT_SCHEMA = Marketing;
GO
EXEC sp_addrolemember 'db_owner', 'sagarreadonly';
GO
The new user is created as 'db_owner' to the specified database.
For more details about database roles, please see Database-Level Roles.
About login and user:
A login is used for user authentication
A database user account is used for database access and permissions
validation.
Logins are associated to users by the security identifier (SID). A login is required for access to the SQL Server server. The process of verifying that a particular login is valid is called "authentication". This login must be associated to a SQL Server database user. You use the user account to control activities performed in the database. If no user account exists in a database for a specific login, the user that is using that login cannot access the database even though the user may be able to connect to SQL Server.
A Login is an identity used to connect to a SQL Server instance. A User allows you to log into a SQL Server database and is mapped to a Login. So you will need to first create a Login, before you can create a User in SQL Server.
Hope this helps.
You can create a "Database login" dialog box to prompt a user for database connection information by using text boxes, buttons, or other dialog box controls. Typically, when you type text in a text box, the text appears as you type. However, you can use a property of the Microsoft Visual Basic for Applications (VBA) Edition User Form to create the effect of a hidden or "masked" text box for creating a password dialog box, where you do not want the text that is typed in a text box to be "visible". Here you will find how to do that.
The information the user types on the "Database login" can be used to build the connection string you posted above.
To create a custom dialog in Excel please follow this instructions.

Password reset for Azure database

I have a new Azure account. I am able to log into the 'manage' page as admin, but I forgot the password to one of my databases. I would like to reset the password on that one DB. How do I do that? Microsoft doesn't seem to have a KB on that - at least not one I could find. Thx.
If you're referring to the administrative password for a specific Windows Azure SQL Database server, you can do this from the new portal. Select the Database choice on the left, then select Servers:
Then, after selecting the server of choice, you'll see the option on the right for resetting admin password:
Using the new azure portal:
https://portal.azure.com
Click browse (to view all resources)
Select SQL databases
Choose a database that's in the server you want to change creds for.
Select the server name url for that selected database. This should open up the server configuration blade.
Reset password is the second button from left.
Another variation on new Azure portal (bypassing the database), #1 go to SQL servers directly; #2 click on the DB Server you want to update the password for, #3 click the pencil, #4 update the password, confirm and save.
To reset the administrator password for a SQL Database server, use the following steps:
Go to the Windows Azure Management Portal at http://manage.windowsazure.com and click SQL Databases in the left-hand navigation pane.
Click the Servers tab at the top of the SQL Databases workspace. This will launch the Server List View.
In the Server List View, click the name of the server to update. This will launch the Server Dashboard.
On the Server Dashboard, click Reset Administrator Password under quick glance tasks on the right-hand side of the workspace.
On the Reset Password dialogue, specify a new password and then confirm the new password.
To complete the operation, click the Check mark button at bottom right. You will be returned to the Server Dashboard for the server.
If you reset the SQL Database server password during a time when there are active connections to databases on the server, you may want to use the KILL statement to terminate user sessions. This will force client connections to refresh their sessions with the database and the host server. For more information, see KILL (Windows Azure SQL Database).
With the current iteration of the interface, the process is similar to what is described above with an additional step:
Get to the Overview as described above.
New: Click on the server name (I just had to stumble into it. Horrible UI design.)
Now there is an option to reset the password.
You can use the following command with the Azure CLI 2.0 to change / reset the password for Azure SQL Database:
az sql server update -n {database server name}
-g {resource group name}
-p {password}
Source: https://buildazure.com/2017/05/18/azure-cli-2-0-reset-azure-sql-database-password/
You can actually reset your admin password to your SQL database using the old/previous Silverlight portal.
Log into https://windows.azure.com/ or into the current one and select "Previous portal" from your login
In the previous portal click the "Database" menu item on the bottom left
Select the database from the subscription
click the "reset password"
Update for new portal:
Go to the SQL server that's hosting your SQL DB and click on "Reset password".
If someone had forgotten his password for DB, First of all, look at the connection string(appsettings.json).
You will find it there.

How to access Azure web site's database

I created a Wordpress web site in Azure. Is there anyway to access the database that was set up along with it? (so I can back / or if I should want to Migrate in the future )
If you go to the website dashboard tab, you will see a link call "view connection string". If you click that you will see the connection string with database and server name, user name, and password , etc. You should be able to use those to log into your MySql database using tool such as http://dev.mysql.com/downloads/gui-tools/5.0.html

SharePoint BCS SSS Help Needed

I'm trying to bring external content into our SharePoint environment. We are running SP 2010. The data I want to bring in exists in Sql Server. What I'm struggling to do is map the logged in SharePoint user to an underlying sql user.
In SharePoint I have created a new Target Application in the Secure Store Serivce:
Target Application ID: TestApp
Target Application Type: Group
I have specified two fields:
Name :: Type
User Name :: User Name
Password :: Password
--these are not the Windows User Name and Windows Password types just the basic types
Target Application Administrators and Members are both set as myself (AD User).
In SharePoint Designer I've created a new External Content Type. I've added a connection of (Type -> Sql Server). I've set the database server name to the server name that is not on the same box as SharePoint and I've set the database name. I've selected the Connect with Impersonated Custom Identity option and set the Secure Store Application Id to TestApp. When I click OK I get prompted for credentials so I enter the Sql Server user credentials and the connection succeeds. I expand out the tables, right click the table I want accessible, and click Create All Operations. I go through the wizard and enter one limit filter.
Next I right click MyTable in the External Content Types windows, select External List, and give it a name. Next I go into Central Admin and set the credentials of TestApp.
Now when I log into SharePoint I can see my external list in the left hand TOC. I click on the list and I get the error Access Denied by Business Data Connectivity with a correlation code. I've opened up the logs to see what is being returned which has some interesting logs but I'm not sure exactly how to remedy the problem:
Log:
Access Denied for User '0#.w|domain\myuser, which may be an impersonation by 'domain\myuser'. Securable MethodInstance with Name 'Read List' has ACL that contains
Another Log:
Error while executing web part: Microsoft.SharePoint.SPException: Access denied by Business Data Connectivity. ---> Access Denied for User '0#.w|domain\myuser', which may be an impersonation by 'domain\myuser'. Securable MethodInstance with Name 'Read List' denied access.
I know if I'm using pass through creds we will need kerbors to handle the double hop but didn't think I would need kerbos with cred mapping to a sql server user.
Any help would be greatly appreciated!!!!
I was playing around with BCS and ran into what I think is a similar problem. This helped to solved the problem. See if this helps
http://www.zimmergren.net/archive/2010/05/08/access-denied-by-business-data-connectivity-solution.aspx
This happens because you have not set access on the BCS object that you created. Go into Central Administration and select your External Content Type or other object and select Set Permissions from the dropdown. Your authentication is working or you would not be able to save the object you created to the metadata store. You now need to tell the metadata store who has access to the objects you created in BCS.

Resources