[VB2005] Getting Windows account name using Windows Authentication
Anyone know how to get the name on the windows account using windows auth such as "Joe Smith"?
Re: [VB2005] Getting Windows account name using Windows Authentication
Try Request.LogonUserIdentity.Name
Re: [VB2005] Getting Windows account name using Windows Authentication
Thank you but no luck. It gives me "DOMAIN\username".
I would imagine if Windows can authenticate you then you should be able to obtain other account attributes.
Anyone have any suggestions?
Re: [VB2005] Getting Windows account name using Windows Authentication
Re: [VB2005] Getting Windows account name using Windows Authentication
How can I query the active directory without specifing a password? I am using Windows Authentication therefore the user is not typing in their logon info.
Re: [VB2005] Getting Windows account name using Windows Authentication
Change the query to search for the authenticated user, e.g. "(&(objecttype=person)(sAMAccountName=foo)", then use a "system" account to execute the query.
Re: [VB2005] Getting Windows account name using Windows Authentication
Can you provide a more detailed example? I am not following. Thanks.
Re: [VB2005] Getting Windows account name using Windows Authentication
I understand the search query, but what do you mean by a "system account to execute"?
Can you provide an example?
Re: [VB2005] Getting Windows account name using Windows Authentication
Make sure that Anonymous User are not allowed. In the Web Config, set
VB Code:
<authorization>
<deny users="?"/> ' "?" means anonymous user
</authorization>
Also check in IIS that Integrated Windows Authentication box is checked.
and in your code behind:
VB Code:
System.Security.Principal.IPrincipal user;
user = System.Web.HttpContext.Current.User;
string name = user.Identity.Name;
'Display name
Re: [VB2005] Getting Windows account name using Windows Authentication
Thanks but it gives me the 'username'. I need the account name or common name such as 'John Doe'.
Does anyone know how to obtain this without using LDAP?