Get UserPrincipalName

D

Dan

Hi,

Is it possible to get the UserPrincipalName of a user from the
WindowsIdentity object ? I'm only able to get the sAMAccount from
WidowsIdentity.GetCurrent().Name.

Thank you !
 
V

Vadym Stetsiak

Hello, Dan!

IMO UserPrincipalName is an Active Directory (AD) attribute. So, having
WindowsIdentity you're to be able to query
for UserPrincipalName using DirectoryServices.

--
With best regards, Vadym Stetsiak.
Blog: http://vadmyst.blogspot.com


You wrote on Tue, 06 Nov 2007 15:04:19 -0000:

D> Hi,

D> Is it possible to get the UserPrincipalName of a user from the
D> WindowsIdentity object ? I'm only able to get the sAMAccount from
D> WidowsIdentity.GetCurrent().Name.

D> Thank you !
 
L

Larry Smith

Is it possible to get the UserPrincipalName of a user from the
WindowsIdentity object ? I'm only able to get the sAMAccount from
WidowsIdentity.GetCurrent().Name.

Don't know if there's a .NET function for this but you can always P/Invoke
to "GetUserNameEx()" in the WinAPI. Note that the last time I did this
however (a few years back), you had to be running in a domain to retrieve
the name in any format other than "NameSamCompatible" and "NameDisplay" (see
the EXTENDED_NAME_FORMAT parameter for the latter function). Otherwise the
function would fail and "GetLastError()" would return ERROR_NONE_MAPPED (as
mentioned in this function).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top