Otis Ranger
 New Member
 Posts:32

 |
| 27 Apr 2012 05:31 AM |
|
I am currently trying to create a LighSwitch App for my company using the existing SQL database. Unfortunatly, the authentication type is set to Windows mode only and this cannot be changed which is a major issue as when I try and publish the application it states that the user connection cannot be a trusted connection (i.e. use mixed mode).
Is there any way around this?
The annoying thing is that it is a Microsoft product that is using the Microsoft SQL database that insists that it is in Windows mode only and I am trying to use another Microsoft product that needs it in another way!!! |
|
|
|
|
Michael Washington
 Posts:990

 |
| 27 Apr 2012 05:37 AM |
|
You can use WCF RIA Services to get around any issues. You are able to set the connection string for any WCF RIA Service, in the web.config of the published LightSwitch application. |
|
----------- Michael Washington http://LightSwitchHelpWebsite.com |
|
|
Otis Ranger
 New Member
 Posts:32

 |
| 27 Apr 2012 05:42 AM |
|
Wow, that was a quick reply!
This was what I was thinking but even when I use a WCF I still seem to get the error. I am going to try angain and post the Fiddler feed here just to make sure I am not doing anyting too stupid. |
|
|
|
|
Michael Washington
 Posts:990

 |
| 27 Apr 2012 05:47 AM |
|
With WCF RIA Services LightSwitch simply says "give me the data, I do not care how". This is why I believe that any issues of connecting will be avoided. However, in most of the examples on this site I use the LightSwitch connection string "_IntrinsicData". In your case you do not want to do that but to use your own connection string. |
|
----------- Michael Washington http://LightSwitchHelpWebsite.com |
|
|
Otis Ranger
 New Member
 Posts:32

 |
| 27 Apr 2012 05:49 AM |
|
When I run the app I get the dreadded Red X and Fiddler reports the following.
Login failed for user ''. The user is not associated with a trusted SQL Server connection.
The webserver is set up to use Windows Integrated Authentication and as far as I can see all the connections are ok.
Your help is really appreciated. |
|
|
|
|
Otis Ranger
 New Member
 Posts:32

 |
| 27 Apr 2012 05:51 AM |
|
So do I replace the _IntrinsicData string with my own connection string? |
|
|
|
|
Michael Washington
 Posts:990

 |
| 27 Apr 2012 05:59 AM |
|
Yes |
|
----------- Michael Washington http://LightSwitchHelpWebsite.com |
|
|
Otis Ranger
 New Member
 Posts:32

 |
| 27 Apr 2012 06:02 AM |
|
Thought that may be the answer and tried it. It now tells me the log in error message within a pop-up on the application rather than hidden in the back end. If all the data sources I use are external, do i need the _IntrinsicData listed at all? |
|
|
|
|
Michael Washington
 Posts:990

 |
| 27 Apr 2012 06:21 AM |
|
If all the data sources I use are external, do i need the _IntrinsicData listed at all? I have never tried all external data so I do not know. Sorry. |
|
----------- Michael Washington http://LightSwitchHelpWebsite.com |
|
|
Otis Ranger
 New Member
 Posts:32

 |
| 27 Apr 2012 06:24 AM |
|
Your help so far has been very much appreciated anyhow. So far I have tried replacing the _IntrinsicData, removing and changing and at the moment I still keep getting the same message of Login failed for user ''. I have a feeling that it may still be something to do with LightSwitch wanting to use the .mdf it creates by default but I cannot be 100% sure yet. I will keep going though. |
|
|
|
|
Otis Ranger
 New Member
 Posts:32

 |
| 27 Apr 2012 06:38 AM |
|
PROGRESS!!!!
I have made a few other changes and realised that as part of the publishing process a DB was created on the SQLExpress instance of my dev machne that listed all the roles, users, applications, profiles etc (not sure if this always happens or as part of trying to get it to work I instigated this) so I cleaned and rebuilt the application making sure that the _IntrinsicData connection was pointing to this SQL DB and I have a new error message:-
Cannot Open Database 'PES' requested by the login. The Login Failed.
Login Failed for user 'MyMachine\ASPNET'
This I am assuming is the username that the app pool is running under so if I either change the user that this uses or add the login to the DB I should be there! 
|
|
|
|
|
Otis Ranger
 New Member
 Posts:32

 |
| 27 Apr 2012 07:11 AM |
|
I think that I have solved it! (With Michael's help of course!)
I have added the MachineName\ASPNet login to the Database with basic read access and then added
to the web.config file and I can now see the app in the browser!
I am not counting chickens yet though as it is just me that can see this at the moment. I need to do more testing but will report back. |
|
|
|
|
Otis Ranger
 New Member
 Posts:32

 |
| 27 Apr 2012 07:13 AM |
|
Sorry, above quote stripped out the XML that I added to the web.config. It should have said how i added
<identity impersonate="true"/>
|
|
|
|
|
Otis Ranger
 New Member
 Posts:32

 |
| 27 Apr 2012 07:44 AM |
|
Ok. So "locally" it now all works, but if I go to another machine and try I see the following error on the trace logs:- Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. So close. |
|
|
|
|
Otis Ranger
 New Member
 Posts:32

 |
| 27 Apr 2012 07:53 AM |
|
Almost there.
I have now amended the web.config again so where I had last put
<identity impersonate="true" />
I have now put in
<identity impersonate="true" userName="MyUserName" password="MyPassword" />
and this now works. Downside to this is that I now have a domain username and password in clear text in the web.config file.
Any ideas on how to get around this? |
|
|
|
|
Michael Washington
 Posts:990

 |
| 27 Apr 2012 08:23 AM |
|
Any ideas on how to get around this? Sorry I am no help at this point I have my hands full on programming isses. Server deployment makes me crazy. |
|
----------- Michael Washington http://LightSwitchHelpWebsite.com |
|
|
Otis Ranger
 New Member
 Posts:32

 |
| 04 May 2012 04:51 AM |
|
I think that I have finally solved this problem.
Along with all of the points and tries above this post also was a help\confirmation of what I already suspected.
I have used a domain login that has as little access to the DB as possible and used this login for the ASP.Net running process. Another small change is when setting up the IIS Server I have allowed it to install SQLExpress and made sure that this is in Mixed mode. This ensures that the packages can be deployed from LightSwitch itself with no errors and keeps all the app housekeeping separate from the data. You still have to add the identity impersonate line but everything else is pretty standard.
Hope this post helps out someone else who is trying to run LightSwitch in Windows only mode  |
|
|
|
|