@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: Converts a directory service object name from one format to another. !!!!C# Signature: [DllImport("secur32.dll", SetLastError=true)] static extern int TranslateName(string accountName, int nameFormat, int desiredFormat, StringBuilder translatedName, ref int userNameSize); !!!!VB Signature: Declare Function TranslateName Lib "secur32.dll" (TODO) As TODO !!!!User-Defined Types: None. !!!!Alternative Managed API: Do you know one? Please contribute it! !!!!Notes: This may be required to obtain the UPN (or other format) of a user's credentials. Minimum supported OS is Windows 2000. Full documentation of the native API is available from http://msdn.microsoft.com/en-us/library/ms725484(VS.85).aspx. !!!!Tips & Tricks: Please add some! !!!!Sample Code: public class Sample { enum EXTENDED_NAME_FORMAT { NameUnknown = 0, NameFullyQualifiedDN = 1, NameSamCompatible = 2, NameDisplay = 3, NameUniqueId = 6, NameCanonical = 7, NameUserPrincipal = 8, NameCanonicalEx = 9, NameServicePrincipal = 10, NameDnsDomain = 12 } [DllImport("secur32.dll", SetLastError=true)] public static extern int TranslateName(string accountName, int nameFormat, int desiredFormat, StringBuilder translatedName, ref int userNameSize); public string GetTranslatedName(string domain, string user) { string samCompatibleName = domain.ToUpper() + "\\" + username; StringBuilder translatedName = new StringBuilder(1024); int userNameSize = translatedName.Capacity; if (0 != TranslateName(samCompatibleName, (int)EXTENDED_NAME_FORMAT.NameSamCompatible, (int)EXTENDED_NAME_FORMAT.NameUserPrincipal, translatedName, ref userNameSize)) { // Make sure we got a UPN out as expected if (translatedName.ToString().Split('@').Length == 2) { return translatedName.ToString(); } } return null; } } Documentation: TranslateName@msdn on MSDN
Edit secur32.translate...
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.