You are here:   Forum
Register   |  Login

Forum Notice

For new Visual Studio LightSwitch questions,
It is recommended that you use the official Visual Studio LightSwitch Forums at:

http://social.msdn.microsoft.com/forums/en-US/lightswitch/threads


Forums

Publishing Lightswitch App using SQL Database with Windows Authentication only
Last Post 04 May 2012 04:51 AM by oranger. 16 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Resolved
Otis RangerUser is Offline
New Member
New Member
Send Private Message
Posts:32
Avatar

--
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 WashingtonUser is Offline
    Send Private Message
    Posts:990
    Avatar

    --
    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 RangerUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:32
    Avatar

    --
    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 WashingtonUser is Offline
    Send Private Message
    Posts:990
    Avatar

    --
    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 RangerUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:32
    Avatar

    --
    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 RangerUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:32
    Avatar

    --
    27 Apr 2012 05:51 AM
    So do I replace the _IntrinsicData string with my own connection string?
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:990
    Avatar

    --
    27 Apr 2012 05:59 AM
    Yes
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    Otis RangerUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:32
    Avatar

    --
    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 WashingtonUser is Offline
    Send Private Message
    Posts:990
    Avatar

    --
    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 RangerUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:32
    Avatar

    --
    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 RangerUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:32
    Avatar

    --
    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 RangerUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:32
    Avatar

    --
    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 RangerUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:32
    Avatar

    --
    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 RangerUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:32
    Avatar

    --
    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 RangerUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:32
    Avatar

    --
    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 WashingtonUser is Offline
    Send Private Message
    Posts:990
    Avatar

    --
    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 RangerUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:32
    Avatar

    --
    04 May 2012 04:51 AM
    • Accepted Answer
    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
    You are not authorized to post a reply.


    Latest Microsoft Visual Studio LightSwitch Forum Threads That Have Answers

    Thanks for help on this, Looking at moving from Access and I'm impressed with the deployment possibilities of LS along with the RAD focus (great name too - Lightswitch). Struggling with something that I'm sure is simple but I'm missing - how do I add a column/field to a query or a datagrid from a related table in LS.  I've tried adding a Data Item in a screen, bit I can't add a field to the grid, and there doesn't seem to be any options to add fields in the query builder. What am I missing folks? Brad
    Read more...

    I have a very big problem.  I created and published a LS application - VS2012 and got this error is generating the program with both the web client mode and desktop clients.  I started this post because I unsuccessfully tried all the solutions I've found on the internet. My application is 3 tier levels  In particular: the IIS server is Windows 2008R2 and is within a domain with multiple servers. The database is on another server Windows 2008R2 with SQL Server 2008R2.  The Lightswitch IIS server has been configured using the Web Platform Installer 4.5  As mentioned on various blogs:  - On IIS7 I checked authorization, first anonymous ASP only, then with authorization Form  - I tried to do the repair of the framework 4.0 and restart both the Web server (Web mode) and the client (in desktop mode)  - I plugged in the web.config section:    <system.webServer>     
    Read more...

    How to set entity properties value in .beforeApplyChange event at client side. Thanks for your help. -SK SK
    Read more...

    Hi, my app created with VS2012 has silverlight client with forms authentication and I am trying to web-deploy to IIS server with database and client on same machine. Until now I was reading so many tutorials and watched many different tutorial-videos. So far I managed to deploy my website to the server without any errors in VS. am I ready now? however, if i try to start my app I use the link http:  / / <serveripv4> / <myappname> but I get "Server error 403 forbidden". I look inside the directory on the Server C:\inetpub\wwwroot\<myappname> and find a subdirectory "Client" with a file default.htm I am wondering what is the right lik to my app? If I use the link http:  / / <serveripv4> / <myappname> / Client I get the loading-percentage-view and at the end I get "error in database communication" it seems to me the database was not created at all. SQL Management Studio does not show the database and
    Read more...

    Hi On creating a new many to many record, all it has is the 2 fields with keys to the other 2 tables. I need to add fields from the associated tables so that it has searchable fields on the screen. However I cannot seem to bind to the newly created record. This is the code I wrote to add the store name to the new record but it just picks up an existing selected record and not the new one. Please assist. Thanks, Mark. partial void GroupList_Changed(NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (GroupList Gr in e.NewItems) { Gr.StoreName = this.Stores.SelectedItem.Name; } } } Mark
    Read more...

    1234

    Microsoft Visual Studio is a registered trademark of Microsoft Corporation / LightSwitch is a registered trademark of Microsoft Corporation