Link to home
Start Free TrialLog in
Avatar of QC20N
QC20NFlag for Denmark

asked on

Trying to find user

I have moved my small homepage from Windows XP IIS to Windows 7 IIS.

I have this:

if (HttpContext.Current.User.Identity.Name.Contains(strPreWindows.TrimEnd()))
{
   Do this
   Do that
 }
 else
 {
   Response.Redirect("info.aspx?id=updatenotallowed", false);
 }

Open in new window


I did not have any problem to retrieve the user by using this: HttpContext.Current.User.Identity.Name

The content was for an exampel: AD\\DKSOKVK

"strPreWindows" I get from a DB

Now "HttpContext.Current.User.Identity.Name" is empty.

First I thought it was because I didn't have Windows Authentication enabled, but it is enabled.

Can anyone help me?
ASKER CERTIFIED SOLUTION
Avatar of Daniel Van Der Werken
Daniel Van Der Werken
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vinhnl
vinhnl

Which authenticate mode do you use in file web.config ? If it is Forms, you sould change it to Windows


<authentication mode="Forms"/>

==>

<authentication mode="Windows"/>
Are you using a SQL db or Access db for your membership?

Check the aspnet_Applications table and the aspnet_membership table, we are looking for discrepancy with the ApplicationID field in aspnet_membership, they should all be the same as the ApplicationID in aspnet_Applications.

Had a similar issue some time ago, using Forms Authentication for some reason the app started reporting a new and different Membership.ApplicationName and subsequently, when a new user was created, a new ApplicationID. The new user able to login, but the existing users could not, because the combination of UserID and ApplicationID being passed by the membership provider, didn't match any UserID and ApplicationID combinations in the db.

I know you are using Windows Authentication, but wondering if the domain part of your login has changed "AD\\"; and is subsequently being interpreted as a different ApplicationID.

Try creating a new user, check the applicationID of the new membership user against the existing membership user record.

Alan