Question Authentication Cookies

Buho1

Member
Joined
Mar 23, 2006
Messages
12
Location
Maryland, USA
Programming Experience
10+
I'm converting an app from .NET 2 to .NET 4. The old app worked fine but the new one doesn't want to log in any user.

I'm using Forms authentication for an ASP.NET application. I'm using the SQL Membershop provider in combination with an LDAP server.

On my login page I have Login1_Authenticate() where I handle the authentication logic myself by testing the user against an LDAP server and (if successful) whether the user exists in my Membership database (the password field in the database is ignored). I'm blending authentication (LDAP) with authorization (Membership). If both check out, I set e.Authenticated = True and then let the Login control's DestinationPageUrl send the user off to the main page.

The trouble is that on page load in the main page, Membership.GetUser is now Nothing (null). HttpContext.Current.User.Identity.Name is empty string "". It's as if the user isn't logged in.

Back to my login page, after e.Authenticated = True, I added these two lines:

FormsAuthentication.SetAuthCookie(Me.Login1.UserName, False)
FormsAuthentication.RedirectFromLoginPage(Me.Login1.UserName, False)

Trouble is, that doesn't seem to do anything different. The user still isn't getting logged in.

The Membership provider is functioning correctly. Membership.GetAllUsers.Count returns a positive integer.

I've exhausted Google looking for what it takes to manually log a user in. The two lines above were the best I've been able to find. What am I missing?
 

Latest posts

Back
Top