Hello all,
I'm trying a simple home.aspx page in my web application in this way:
protected void Page_Load(object sender, EventArgs e)
{
Debugger.Break();
var user = Membership.GetUser();
if (user != null)
{
userName.Text = user.UserName;
emailAddress.Text = user.Email;
if (user is ActiveDirectoryMembershipUser)
{
lastLoginDate.Text = "Not available";
lastActivityDate.Text = "Not available";
}
else
{
lastLoginDate.Text = user.LastLoginDate.ToShortDateString();
lastActivityDate.Text = user.LastActivityDate.ToShortDateString();
}
var sidValue = (System.Security.Principal.SecurityIdentifier)user.ProviderUserKey;
if (sidValue != null)
sid.Text = sidValue.ToString();
}
}
to get user information from Active Directory authentication:
My scope is to know the user in my web app without force users to insert username/password, but just only using his A.D. login in the firm intranet.
The problem is that does not work in this way, because I got user = null.
ciupazMI
Member
128 Points
146 Posts
Get user information from Active Directory authentication
Apr 12, 2012 06:52 AM|LINK
Hello all,
I'm trying a simple home.aspx page in my web application in this way:
protected void Page_Load(object sender, EventArgs e) { Debugger.Break(); var user = Membership.GetUser(); if (user != null) { userName.Text = user.UserName; emailAddress.Text = user.Email; if (user is ActiveDirectoryMembershipUser) { lastLoginDate.Text = "Not available"; lastActivityDate.Text = "Not available"; } else { lastLoginDate.Text = user.LastLoginDate.ToShortDateString(); lastActivityDate.Text = user.LastActivityDate.ToShortDateString(); } var sidValue = (System.Security.Principal.SecurityIdentifier)user.ProviderUserKey; if (sidValue != null) sid.Text = sidValue.ToString(); } }to get user information from Active Directory authentication:
My scope is to know the user in my web app without force users to insert username/password, but just only using his A.D. login in the firm intranet.
The problem is that does not work in this way, because I got user = null.
What's wrong in my approach?
Thanks in advance.
Luigi
vijayst
All-Star
16558 Points
3216 Posts
Microsoft
Re: Get user information from Active Directory authentication
Apr 12, 2012 07:06 AM|LINK
Integrated Windows Authentication must be turned on in IIS for this to work.
http://liteblog.codeplex.com
ciupazMI
Member
128 Points
146 Posts
Re: Get user information from Active Directory authentication
Apr 12, 2012 07:32 AM|LINK
So I have to deploy in IIS my test web application?
Luigi