Windows Security and retreiving User Principal Name (UPN)

I'm using Windows security on a NetTcp binding. I'm developing client application (not a network service) that will typically run the user's domain or local account.

From what I understand, from entries likehttp://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=434681&SiteID=1, I will need to provide the UPN for Kerberos to perform authentication.

I find it surprising that I need to provide the UPN identity to be used in the formuser@domain. I'd like to use the UPN corresponding user's domain account -- is there an easy way to determine the user's UPN, other than hitting active directory?

I looked around, and the username provided bySystem.Security.Principal.WindowsIdentity.GetCurrent() is of the NetBIOS form domain\name, and it does not use the full domain name.

Any help would be appreciated... Thanks!

[1140 byte] By [d.mac] at [2007-12-21]
# 1

Actually you can provide the UPN in the domain\username format. I just tested it and it worked as expected:

This worked:

<endpoint address="http://sauron:8000/ScottsService/"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IBlah"
contract="IBlah"
name="WSHttpBinding_IBlah">
<identity>
<userPrincipalName value="smason@redmond.corp.microsoft.com" />
</identity>
</endpoint>

As did this:

<endpoint address="http://sauron:8000/ScottsService/"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IBlah"
contract="IBlah"
name="WSHttpBinding_IBlah">
<identity>
<userPrincipalName value="Redmond\smason />
</identity>
</endpoint>

ScottMason at 2007-9-10 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 2

Also, you can also use this to get the full domain/username:

string username = Environment.UserDomainName + "\\" + Environment.UserName;

Thanks,

Scott

ScottMason at 2007-9-10 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...

Visual Studio Orcas

Site Classified