This Class is useful for Creating FormAuthentication.
using
System;
using
System.Collections.Generic;
using
System.Linq;
using System.Web;
using
System.Web.Security;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
using
System.Net.NetworkInformation;
using
System.Management;
using
System.Security.Principal;
namespace
AIMS_Shared
{
public class
FormAuthentication
{
public FormAuthentication()
{
}
#region
::This Method is use for creating Formauthentication ticket and cookie::
public void
CreateFormAuthenticationTicket(string userid,
string UserData,
HttpResponse httpResponse)
{
// Create a new ticket used for
authentication
FormsAuthenticationTicket
ticket = new
FormsAuthenticationTicket(
1, // Ticket version
userid, // Username to be
associated with this ticket
DateTime.Now,
// Date/time issued
DateTime.Now.AddHours(14),
// Date/time to expire
true,
// "true" for a persistent user cookie (could be a
checkbox on form)
UserData, // User-data (the roles
from this user record in our database)
FormsAuthentication.FormsCookiePath);
// Path cookie is valid for
// Hash the cookie for transport over the wire
string hash =
FormsAuthentication.Encrypt(ticket);
HttpCookie cookie =
new HttpCookie(
FormsAuthentication.FormsCookieName,
// Name of auth cookie (it's the name specified in
web.config)
hash); //
Hashed ticket
cookie.Expires =
DateTime.Now.AddHours(14);
httpResponse.Cookies.Add(cookie);
}
#endregion

Ramesh KPPosted Dec 8, 2012, 5:11 AM
Can u pls do me a favour .create custom service behavior to authenticate all service call in wcf
Ramesh KPPosted Dec 8, 2012, 5:10 AM
thanks........!!!!!
surender bhyanPosted Apr 1, 2011, 7:15 AM
Thanks so much Bro...