Showing posts with label broker. Show all posts
Showing posts with label broker. Show all posts

Tuesday, February 14, 2012

Cross Domain Windows Endpoint Authentication?

Hi There

I have service broker working 100% with an initiator - forwarder - target, all in the same domain using windows authentication on the endpoints, for all instances' the sql server service run under the same domain account, which in turn is granted connect on the various endpoints. This all works 100%

However i have a scenario where the initiator will be in a different trusted domain.

I need to know if i am correct in thinking that the initiator sql server servcie account can run under DomainA\sqlservice, the target instance sql server servcie can run under DomainB\sqlservice, then on the forwarder i simply grant connect on the forwarder endpoint to both DomainA\sqlservice and DomainB\sqlservice.

Is this correct, will this work?

Thanx

The initiator and acceptor both authenticate each other. There have to be a mutual trust relationship between domainA and domainB. Often this is not possible in practice, this is when certificate based authentication can be used instead as an alternative. Note that an endpoint can support both types of authentications simultaneously.

HTH,
~ Remus

|||

Hi Remus

Thank you for the response.

So the forwarder simply forwards the message and credentials between initiator and target, correct?

The fact that the forwarder can connect to either does not resolve the matter?

Thanx

|||

The forwarder forwards messages and messages have all the necessary means to authenticate services using certificates (the service owner and remote service binding stuff). No windows authnetication is required, nor possible, at the message level, so no real Windows credential forwarding occurs (in the terms of Kerberos delegation and such).

The endpoint authentication (the GRANT CONNECT ON ENDPOINT::... and SQL Service account stuff) refers to allowing two processes (SQL Server) to authenticate each other in order to exchange messages. This can be Windows or certificate based (to be precise, is TLS as provided by schannel SSPI)

So if a forwarder F (in DomainF) sits between two machines A (in DomainA) and B (in DomainB) then the forwarder has to be able to connect to both A and B, it can use Windows or Certificate based authentication for either of these connections. So, if Windows authentication is used, DomainA and DomainF must have a trust relationship and DomainF and DomainB must also have a trust relationship. However, absolutely no requirement exists between DomainA and DomainB directly, since A and B never directly connect. The only 'authentication' between A and B happens only at the higher level of the SSB services and is always based on certificates.

BTW, to be absolutely accurate (and just to complicate things in case were too easy to understand), when a SQL Server SSB in DomainA whishes to connect to a SQL Server instance in DomainB (and viceversa) mututal trust is not required, one way trust is enough. But if one way trust is used (say DomainB trusts DomainA but not viceversa) the SQL Server instance in the untrusted domain (DomainB in our case) must be installed to run as an user in the trusted domain (DomainA\user)

HTH,
~ Remus

|||

Hi Remus

Thank You for the reply.

I must admit though i am a bit more lost.

Either way i cannot even get the first thing to work. We have Domain A and Domain B, i 1 way trust relationship exists between DOmainA and DomainB, that is DomainB trusts DomainA.

BUT, if you go onto the sql server instance in DomainB, i can go to Users ANd groups and add a DomainA user, so the instance in DomainB can authenticate DomainB accounts, HOWEVER when i go into sql server management studio and create a new login, DomainA\user , it says that it cannot find sucha user or group, i can click the search by the login name navigate to domainA and find the user but when i click ok i get the same error message, so i really dont know whats going on, since at a windows level i can add DomainA users but not in sql server?

So obviously there ar emore issues than simply this.

Just to clarify the scenario is as follows.

Initiator - DomainA

Forwarder DomainB

Target DomainB

- 1 way trust relationship between DomainA - DomainB, DomainB trusts DomainA.

Intiator sql service account runs under DomainB user, i want to make the forwarder service account run under a Domain B account but like i said i cannot add the login in sql server even though i can add the user ont he server innormal windows?

ANyway thanx for the help , this is a serious issue, i think we may open a microsoft case to resolve it today, or move a bunch of servers to the other domain, either way lots of fun awaits.

Cheers

|||

What happens is that the SQL Server process running in DomainB cannot authenticate itself with DomainA to interogate the Active Directory (because its service account is in DomaniB and DomainA does not trust it). Open a query window to the SQL instance in DomainB and run this statement:

EXECUTE AS USER = 'DomainA\SomeUserName';

It will give an error with an OS error code, that code is the explanation why you cannot create users of DomainA on the instance on DomainB.

One way would be, as I mentioned above, to run the instance in DomainB (say the Forwarder) as an user in DomainA (that, specify the service account). But once you do this, you will ot be able to authenticate the Forwarder with the Target (for the same reasons). If you cannot establish mutual trust your only way out is certificate based authentication between Initiator and Forwarder.

HTH,
~ Remus

Cross DB dialog security issues. Was: Can't Route to another LOCAL Broker Instance

Hi Remus,

I am experiencing the same problem, and I can't get the easy fix to work. I drop and create the DB's in between tests, so it is not related to having an old certificate in the DB, as in the case of Tilfried.

The situation is as follows:

DB1 owned by login1, has a user for login2; this DB is for the initiator

DB2 owned by login2, has a user for login1; this DB hosts the target

Both DB's have TRUSTWORTHY flag set to ON

Error in sys.transmission_queue: 'Error 916, State 3: The server principal "Login1" is not able to access the database "DB2" under the current security context.

Going on a limp, I decide to add a remote service binding in DB1, binding the user for Login2 to the target service, even though BOL explicitly states that this is only required for cross-server communications. This does change the situation - I still get an error, but a new message is sys.transmission_queue: "Dialog security is unavailable for this covnersation because there is no certificate bound to the database principal (Id: 5). Either create a certificate for the principal, or specify ENCRYPTION = OFF when beginning the conversation." I already know that the first option works, but I wanted to get the simple solution running. As for the second option, I doublechecked and the initiating procedure DOES already specify ENCRYPTION = OFF in the BEGIN DIALOG CONVERSATION command. My theory is that the remote service binding somehow forces SB to use encryption, but (a) that is not stated in the error message, and (b) if so, then how to get the messages sent over to the target service without using the binding?

==> EDIT: Just saw that you confirmed this theory in your last reply to Tlifried. So I am indeed back to having to find out how to get this to work without remote service binding - it should be possible, but how?

BTW, SELECT @.@.VERSION shows that I'm on build 3054, in case it matters.

Between all the errors in BOL and less than helpfull error messages produced by SB, I feel like I'm slowly losing my sanity. Please help!

Best regards,

Hugo Kornelis

Hi Remus (or whoever is listening),

Just to make sure that I'm not looking in the wrong corner, I decided to make sure that the absence of certificates is the ONLY reason that the services won't talk to each other. So I made certificates for the dbo owner in each of the DBs, dumped them to file and used those files to create certificates for the corresponding users in the other DBs.

After setting up certificates like that, I still got the same error (Error 916, State 3) - but once I added a remote service binding, my dialog ran without further problems.

I still don't understand why a remote service binding is required even though BOL says (quote from the CREATE REMOTE SERVICE BINDING page): "A remote service binding is only necessary for initiating services that communicate with target services outside of the SQL Server instance." - but at least I am now certain that my problems with the version without certificates and with the trustworthy option set on are not related to any other errors in my setup.

Best, Hugo

|||

On the interaction between ENCRYPTION = ON/OFF and the presence/absence of a remote service binding see http://blogs.msdn.com/remusrusanu/archive/2006/07/07/659319.aspx. When a RSB is present, the login mapping between databases is discarded in favour of certificates. This is intentional, as a way to circumvent the problem of no wanting to enable TRUSTWORTHY bit (with all the instance level implications).

To map users trough logins, having TRUSTWORTHY ON is a required condition, but not suficcient. The complete story is detailed at http://msdn2.microsoft.com/en-us/library/ms188304.aspx. What you need is for DB2 to grant AUTHENTICATE permision to login1. TRUSTWORTHY bit is required only on DB1. This is nothing specific to Service Broker, using EXECUTE AS user = 'foo' in DB1 and then issue a USE DB2 statement would run into the same error.

I understand the errors are somehow cryptic and misterious, now the cat is out of the bag we hope to get better at next iteration. Tools would shorley help, give a shot to www.codeplex.com/slm

|||

Hugo Kornelis wrote:

I still don't understand why a remote service binding is required even though BOL says (quote from the CREATE REMOTE SERVICE BINDING page): "A remote service binding is only necessary for initiating services that communicate with target services outside of the SQL Server instance."

Remote service bindings are required for remote dialog security. However, altough not required, if present, they are honored for local dialogs.

|||

without reading the whole thread in detail, I found that the SQL Profiler lets you find problems within minutes, for which you would normally take hours or days of checking everything!

Trace shows messages and errors, you will never receive through SSB directly!