Benutzer mit den meisten Antworten
Benutzerauthentifizierung mit securityMode="None"

Frage
-
Hallo,
ich möchte gerne, dass man sich an meinem WCF Service ganz klassisch über eine Login Methode anmelden muss ohne securityMode und clientCredentialType.
Die Benutzerdaten sollen in einer eigenen Tabelle „customers“ stehen.
Hat da jemand einen guten Ansatz für mich?
Schon mal Danke und Gruß
Thomas
Donnerstag, 20. Oktober 2011 06:48
Antworten
-
Im Interface:
[OperationContract(IsInitiating = true, IsTerminating = false)]
Boolean login(string username, string password);[OperationContract(IsInitiating = false, IsTerminating = true)]
Boolean logout();[OperationContract(IsInitiating = false, IsTerminating = false)]
string HelloWorld();
Im Servicepublic struct TSession
{
public string SessionId;
public int CustomerId;
}public static List<TSession> sessionliste = new List<TSession>();
public Boolean login(string username, string password)
{
dbEntities context = new dbEntities();
var customer = (from c in context.customers
where c.password == password && c.number == username && c.deactivated == false
select c).FirstOrDefault();
if (customer != null)
{
TSession mySession;
mySession.SessionId = OperationContext.Current.SessionId;
mySession.CustomerId = customer.id;
sessionliste.Add(mySession);
return true;
}
else
{
return false;
}
}public Boolean logout()
{
try
{
string currentSessionId = OperationContext.Current.SessionId;
var s = sessionliste.Where(x => x.SessionId == currentSessionId).FirstOrDefault();
sessionliste.Remove(s);
return true;
}
catch
{
return false;
}
}- Als Antwort markiert Sojus_12 Freitag, 21. Oktober 2011 04:53
Donnerstag, 20. Oktober 2011 07:45
Alle Antworten
-
Im Interface:
[OperationContract(IsInitiating = true, IsTerminating = false)]
Boolean login(string username, string password);[OperationContract(IsInitiating = false, IsTerminating = true)]
Boolean logout();[OperationContract(IsInitiating = false, IsTerminating = false)]
string HelloWorld();
Im Servicepublic struct TSession
{
public string SessionId;
public int CustomerId;
}public static List<TSession> sessionliste = new List<TSession>();
public Boolean login(string username, string password)
{
dbEntities context = new dbEntities();
var customer = (from c in context.customers
where c.password == password && c.number == username && c.deactivated == false
select c).FirstOrDefault();
if (customer != null)
{
TSession mySession;
mySession.SessionId = OperationContext.Current.SessionId;
mySession.CustomerId = customer.id;
sessionliste.Add(mySession);
return true;
}
else
{
return false;
}
}public Boolean logout()
{
try
{
string currentSessionId = OperationContext.Current.SessionId;
var s = sessionliste.Where(x => x.SessionId == currentSessionId).FirstOrDefault();
sessionliste.Remove(s);
return true;
}
catch
{
return false;
}
}- Als Antwort markiert Sojus_12 Freitag, 21. Oktober 2011 04:53
Donnerstag, 20. Oktober 2011 07:45