开发者

SSO get username / domain

I'm trying to implement SSO (Single Sign On) but I can't get the correct username.

At my place, when I retrieve the currently logged on user I get: USER@DOMAIN. Which is correct. When the same code is executed at the customer, it returns: USER@DOMAIN. But in that situation; it is not correct. The expected value at the customer is USER@INTRANET.DOMAIN.

I'm not familiar enough with SSO to say anything about the INTRANET part. At the customer, other software uses SSO as well and therefore it is required that 'my' software formats the user/domain into USER@INTRANET.DOMAIN.

I've tried several pieces of code to retrieve the user/domain of the currently logged in user. The results below are from the customer.

UserPrincipal.Current.UserPrincipalName - returns user@domain 
System.Environment.UserDomainName - returns INTRANET
WindowsIdentity.GetCurrent.Name - returns INTRANET\user

So I'm looking for a way to 开发者_如何转开发retrieve the complete username of the currently logged in user with the 'subdomain' (INTRANET) as well. Does anybody know what I'm doing wrong?

*Edit: * I rephrased my question. I feel like my English is getting worse by day... :S


Try following code.

string domainName = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName;
string nametext = WindowsIdentity.GetCurrent().Name.Split('\\')[1];

//OR 
// string nametext = Environment.UserName;

string fullname = String.Format("{0}@{1}", nametext, domainName);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜