none
ErikEJ.SqlCeMembershipProvider - How to implement credentials validation for file upload service

    Question

  • I am testing a primitive file upload webservice with credentials validation and guessing at the implementation of the  ErikEJ.SqlCeMembershipProvider.ValidateUser method.  The code I am using is as follows:

     Dim ok As New ErikEJ.SqlCeMembershipProvider
            If ok.ValidateUser("UserName", "UserPass") = False Then
                Return "FAIL - BAD CREDENTIALS"
            End If

    But generates the following error:

    System.InvalidOperationException: The ConnectionString property has not been initialized.
       at System.Data.SqlServerCe.SqlCeConnection.Open(Boolean silent)
       at System.Data.SqlServerCe.SqlCeConnection.Open()
       at ErikEJ.SqlCeMembershipProvider.GetUserId(String userName)
       at ErikEJ.SqlCeMembershipProvider.ValidateUser(String username, String password)
       at asw_contrib.UploadFile(String fileName, String uName, String uPass) in ...

    Any suggestions as far as how to embellish the context of my code snippet to implement validation? 

    Thanks.


    -BGood

    Monday, March 24, 2014 7:08 PM

Answers

All replies

  • You should use membership classes, not the provider implementation directly. And make sure your web config is correctly configured.

    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com

    Monday, March 24, 2014 7:36 PM
  • You should use membership classes, not the provider implementation directly. And make sure your web config is correctly configured.

    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com

    ErikEJ, Thank you for this reply, but could you please be more specific as to a resource or documentation of how to use the membership class for validation?  As for web.config, are you talking about removing the references to SQL Express?

    <connectionStrings>
        <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
          providerName="System.Data.SqlClient" />
        <add name="ConnectionString" connectionString="Data Source=C:\Users\...path to database...\Database.sdf"
          providerName="Microsoft.SqlServerCe.Client.4.0" />
        <add name="SqlCeServices" connectionString="data source=|DataDirectory|\SqlCeAspnetdb.sdf" />
        <add name="asw_Repo" connectionString="Data Source=|DataDirectory|\myAnalyzedData.sdf"
          providerName="System.Data.SqlServerCe.4.0" />
      </connectionStrings>


    -BGood

    Friday, March 28, 2014 7:28 PM
  • Lmgtfy - http://msdn.microsoft.com/en-us/library/ff648345.aspx

    Please mark as answer, if this was it. Visit my SQL Server Compact blog http://erikej.blogspot.com

    Friday, March 28, 2014 8:10 PM