|
From: Dan on 6 Nov 2007 10:04 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 !
From: Vadym Stetsiak on 6 Nov 2007 12:36 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 !
From: Larry Smith on 6 Nov 2007 14:44 > 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).
|
Pages: 1 Prev: In-Memory Assemblies Next: Ling to SQL and error recovery |