SQL Server 2012 Management Studio and samba 4 - sql-server

I am experiencing a very weird situation. When logged into my database server with a domain account (which is also a member of the local administrators group) the sa user is unable to connect to SQL Server Management Studio. However, logging in as a local admin account the sa user logs in successfully.
To make things more confusing... when logged into the Windows Server with a domain account (which is also a member of the local administrators group) SQL Server Management Studio will connect using Windows authentication.
A few notes:
While logged into the server with a domain account sa CAN connect via sqlcmd.
sa can connect via ODBC from other workstations on the domain (logged in as a domain user)
The SQL Server authentication is set for SQL Server and Windows authentication mode
The sa user does NOT have "Enforce password policy" checked
I have tried creating a new SQL admin user with the sysadmin role (same issue)
The SQL Server machine is a member of the samba4 domain
My environment:
Database Server
SQL Server 2012 x64 Standard edition with service pack 3
Windows Server 2012 R2 Standard x64
Directory Server
CentOS 6.7 x64
Samba 4.3
smb.conf
[global]
workgroup = XYZ
realm = XYZ.COM
netbios name = DS01
server role = active directory domain controller
dns forwarder = 8.8.8.8
tls enabled = yes
tls keyfile = tls/key.pem
tls certfile = tls/cert.pem
tls cafile = tls/ca.pem
[netlogon]
path = /usr/local/samba/var/locks/sysvol/xyz.com/scripts
read only = No
[sysvol]
path = /usr/local/samba/var/locks/sysvol
read only = No
[home]
path = /home/
comment = Home Directories
# read only = No
browseable = no
writable = yes
create mask = 0600
directory mask = 0700

As I mentioned in my comment. Although there seems to be no answer at this point other than wait for a fix. The workaround is to login as a local user and run SQL Server Management Studio

Related

can't access to sql server from remote client with windows authentification

I've got windows server 2012 and windows 7 on virtual machine connected on the same network, I try to connnect to sql server database on windows server from windows 7 (windows server is member of my domain), but it's always show me this error : login from an untrusted domain,
I connect with a user in my domain , I even tried with administrator
(trying to connect with sql authentification work perfectly)
this is the error

SQL Server connection user varies when using '127.0.0.1' vs 'localhost'. Why?

When I attempt to connect to my local, default SQL Server instance via SQL Management studio using Windows Authentication, I successfully connect when I use Server Name "localhost", but fail when I use Server Name "127.0.0.1". With login auditing enabled for both failed and successful logins, I see that the successful logins are recorded as:
Login succeeded for user 'AzureAD\RealUsername'. Connection made using Integrated Authentication. [CLIENT: < local machine >]
And the failed logins are recorded as:
Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. Reason: Could not find a login matching the name provided. [CLIENT: 127.0.0.1]
Possibly relevant:
I can connect using the ip address if I use SQL Server authentication (since I am forcing it to use an existing login).
There is no entry in my hosts file for "localhost", and when I ping localhost it does resolve to 127.0.0.1.
The SQL instance uses port 1433.
The issue, with very little variation, persists when connecting via SQL Management Studio, a .NET web app running in a local IIS instance, or via UDL file on my desktop.
Here is my question: Why would changing only the server value ('localhost' vs '127.0.0.1') change the identity used when connecting?

Remote connection to SQL server 2008 sp2

I built a window application in visual studio 2010. It is working fine at my computer.
if i have a pc that works with windows server 2008 and i install a sql server on it , how to make my application connect to database in the sql server that instaled in the server pc .
my pc connected to the server domain .
thanks
Assuming your application is already configured to use a Sql connection string, you'll just need to configure it for the Sql Server instance you're connecting to.
For example, if your database is called MyDatabase, and your windows server on your domain is called myserver.local, and you've installed Sql Express with the default SQLEXPRESS instance name, you could create your connection string (assuming ADO.NET) something like this:
Integrated Security=true;Initial Catalog=MyDatabase;Data Source=myserver.local\SQLEXPRESS
This configuration would be for Windows Authentication (Integrated Security=true): so your domain user accounts would need to be granted LOGIN rights on the server, and those Logins associated with USERS and ROLES in your database. If you wanted to use Sql Logins instead (generally requires extra configuration when setting up your Sql Server), there are different connection strings settings for specifying username and passwords. There are many options available for the connection strings as documented here: https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(v=vs.110).aspx. However, with Windows Authentication the only 3 you absolutely need are the ones shown above.
You can test connectivity to your Sql Server from your PC on the network using Sql Server Management Studio, which will enable you to verify the instance name and the authentication is working as expected if you can connect to the database.

How to Connect to My Local Network SQL Server

My desktop machine has SQL Server installed. I can connect to it (using my desktop machine) using the following server name:
localhost\SQL_Express
Windows Authentication
If I want to connect to it using my Laptop, I try to do the following (ACER_ASPIRE is my computer name):
ACER_ASPIRE\SQL_Express
SQL Authentication (acerAspireUserName, acerAspirePassword)
I get an error saying the server wasn't found. How can I go about connecting to my desktop machine's SQL Server from my Laptop?
To connect to a Sql Server you need to specify two things.
1 - Server name
In this section you are suppose to provide [ServerName\InstanceName]
Server Name is the Machine Name where your sql server Instance lives. And obviously since sql server can have multiple instances on one machine you need to provide the instance name that you want to connect to.
There is an exception for Instance name if you are connecting to the Default Instance you dont need to provide full [ServerName\InstanceName] you can only use the machine name to connect to the default instance on sql server on that machine.
One thing you need to know is
localhost == . == MachineName == ServerName
These are all different ways you can tell sql server , the server name that you want to connect to.
2 - Authentication
You have two ways to authenticate yourself when connecting to sql server,
Windows Authentication.
Sql Server Authentication.
In 1st section ServerName you told sql server that which machine and what instance you want to connect to.
Now in this Authentication Section you will have to tell sql server how you will be Authenticated.
When using Windows Authentication Sql server will use your windows credentials to identify you. This has nothing to do with the Server/Machine name it is to do with the Operation system of the machine, in your case it is windows and you can use your windows credentials.
On the other hand if you use Sql Server Authentication you will have to use a Sql Server Login' andPassword`. In this case sql server will not care what operating system you have on your machine. (mostly used when you are working on operation systems other than windows like Linux, Unix, Mac). It will only take consideration the login and password you pass.
Authentication Mode
What Authentication Mode you can use? this depends on your sql server configuration when you were installing, You can set your sql server to Only Allow Windows Authentication or Mixed Mode (i.e Windows Authentication and Sql Server Authentication).
Your Case
In your Case regardless of what Authentication Mode you are using. You can use any notations in sql server SERVER Section as long as they point to your machine like
local, localhost, . , ACER_ASPIRE
But for Authentication if you are using Sql Server Authentication Make sure you are using a Valid Sql Server Login and Password.
Open the query window, and inside it execute the following:
EXEC sys.sp_configure N'remote access', N'1'
GO
RECONFIGURE WITH OVERRIDE
GO
This option is not enabled by defauld on Express edition.
By default, SQL Express doesn't support LAN Connections, only from local machine.
To use it you must configure to listen to network ports also. You can do that on the SQL Server Surface configuration tool.

SQL Server 2008 - Login failed for user 'user1' The user is not associated with a trusted SQL Server connection

I have installed SQL Server 2008 R2 on Windows XP.
In installation process I selected 'SQL Server and Windows Authentication Mode'
When I click right button of the mouse in SQL Server Management Studio on Server -> Security tab 'SQL server and Windows Authentication Mode' is selected.
But when I click on my Database -> Properties - View connection properties Authentication Method is set on Windows Authentication.
To my database was added one user1 with password user1.
But I can't log in to my database from C# (Visual Studio 2008) because error occurs:
Login failed for user 'user1' The
user is not associated with a trusted
SQL Server connection
What isn't right ?
When I get:
string connectionStr = #"Data Source=rmzcmp\SQLExpress;Initial Catalog=ResourcesTmp;Integrated Security=True";
I have following error:
{"Cannot open database \"ResourcesTmp\" requested by the login. The login failed.\r\nLogin failed for user 'RMZCMP\rm'."}
rm is my original user name on which I log in to my computer.
When I get rm I have error:
{"Login failed for user 'rm'. The user is not associated with a trusted SQL Server connection."}
again.
Regards
You say a user was created in your database - did you also create a login to your server?
In SQL Server 2005 and up, security is a two-step process:
you first must define a login that enables a user to even log in to that SQL Server
based on that login, you can define user in your individual databases
Also: you're not showing us your connection string, so we can only guess what settings you're using. From the error message, I'm almost guessing you're using Integrated Security in your connection string - but from your other points in the question, it seems you've created a specific user (and possibly a login for that user) - so you don't want to use integrated (Windows) security...
Most likely, your connection string is invalid - or you're missing a login - or both. You need to give us a bit more information for us to be able to really help!
Can you change your Connection string based on :
Connection string.com
Make sure that your installation of SQL Server is successful.
Ex:
If you can create a SQL Server authentication login
You can login using username/password in SQL Server authentication. Use a connection string like:
Data Source=Servername;Initial Catalog=DatabaseName;User ID=user;Password=sa
But
If you can login using only windows authentication there is something wrong in your installation. Use connection string:
Data Source=Servername;Initial Catalog=DatabaseName;Integrated Security=True
Regards!
That error suggests your application is set to log in with "trusted" (i.e. Windows) credentials and that the Windows account that the program is running as doesn't have a login on the server. Based on the way that you phrased the adding of a user, my guess is that it's a SQL login and you should change your connection string to reflect that.
I created user on my machine (where ms sql is installed)
User name is user1 and password too.
I can log on to Ms sql server on this user (user1)
My connection string is:
string connectionStr = #"Data Source = rmzcmp\SQLExpress; Initial Catalog = ResourcesTmp; User Id = user1; Password = user1;";
I user MS SQL Server 2008
rmzcmp is my computer name.
In ResourcesTmp (my database) ->Security ->Users I have: dbo, guest, INFORMATION_SCHEMA, sys, user1, user2
I don't have sa user.
User1 has following permissions:
Schemas owned by this user:
db_accessadmin
db_datareader
db_datawriter
Database role membership
db_accessadmin
db_datareader
db_datawriter
db_owner
Server properties -> Permissions ->Explicit tab:
Connect SQL : Grantor sa, Grant true.
User1 all checkboxes has false
Security tab -> Server authentication : SQL Serve and Windows Authentication mode is selected as I mentioned in earlier post
Regards
This problem occurs if the user tries to log in with credentials that cannot be validated. This problem can occur in the following scenarios:
Scenario 1: The login may be a SQL Server login but the server only accepts Windows Authentication.
Scenario 2: You are trying to connect by using SQL Server Authentication but the login used does not exist on SQL Server.
Scenario 3: The login may use Windows Authentication but the login is an unrecognized Windows principal. An unrecognized Windows principal means that Windows can't verify the login. This might be because the Windows login is from an untrusted domain.
To resolve this problem, follow the steps that apply to your scenario.
Scenario 1: Configure SQL Server in Mixed Authentication Mode.
SQL Server 2012, SQL Server 2008, and SQL Server 2005
Open SQL Server Management Studio. To do this, click Start, click All Programs, click Microsoft SQL Server 200x (where x is the version of SQL), and then click SQL Server Management Studio.
Right-click the server, and then click Properties. See image.
On the Security page, under Server authentication, click the SQL Server and Windows Authentication mode option button, and then click OK. See image.
In the SQL Server Management Studio dialog box, click OK to restart SQL Server.
see http://support.microsoft.com/kb/555332

Resources