Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

How to check if a user is logged in via a webservice

$
0
0

Using the webforms template from Visual Studio 2013

I have this working and can log in a user. My need is this, I have another system that will be integrated into this website that I'm building. With this integration I'll be sending over a userid of the logged in user to the second application. The second application then in turn needs to call back to the ASP.Net application passing back this user id to make sure they are still logged in. If this returns true then I need another service all where again I can send in this user id and retrieve back information about this user like name and roles. I have added a service to my ASP.net application but get the following error when I try to run this test code.

[WebMethod]
public bool testUser(string userId)
{
bool u_status = false;

MembershipUserCollection users;

users = Membership.GetAllUsers();

foreach (System.Web.Security.MembershipUser u in users)
{
if (u.UserName == "sam")
{
u_status = true;
}
}

return u_status;
}

System.Configuration.Provider.ProviderException was unhandled by user code
HResult=-2146233088
Message=Default Membership Provider must be specified.
Source=System.Web
StackTrace:
at System.Web.Security.Membership.InitializeDefaultProvider(Boolean initializeDefaultProvider, MembershipSection settings)
at System.Web.Security.Membership.Initialize()
at System.Web.Security.Membership.get_Provider()
at System.Web.Security.Membership.GetAllUsers(Int32 pageIndex, Int32 pageSize, Int32& totalRecords)
at System.Web.Security.Membership.GetAllUsers()
at userStatus.testUser(String userId) in c:\Users\John\Documents\Visual Studio 2013\WebSites\Jasper_Example\App_Code\userStatus.cs:line 35
InnerException:


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>