TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ramachandran M
NA
713
22.2k
Could not fetch windows identity name in web api 2.0
Jan 7 2021 5:30 AM
Hi Friends,
I used below code to get windows authentication but it returns empty string after deployed empty string. Yesterday we implimented https certificate after that application failed.
i tried to add impersonate set true and false in web.config but no luck.
string sCurrentUserName = string.Empty;
if (HttpContext.Current.User != null)
{
sCurrentUserName = HttpContext.Current.User.Identity.Name.ToString();
}
if (sCurrentUserName == string.Empty)
sCurrentUserName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
if (sCurrentUserName != null && sCurrentUserName.Trim().Length > 0)
{
string[] splittedName = sCurrentUserName.Split('\\');
if (splittedName.Length > 0)
{
string sDomain = splittedName[0].ToString();
return (splittedName.Length > 1) ? splittedName[1].ToString().Trim().ToUpper() : splittedName[0].ToString().Trim().ToUpper();
}
}
return string.Empty;
Reply
Answers (
5
)
asp.net core seed data with startup
Some PDF documents not loading for editing using persits.pdf tool