/// <summary>
 /// Convert from an Active Directory User Principal Name (UPN) to a down-level NT4 style name.
 /// </summary>
 public static string TranslateUpnToDownLevel(string userPrincipalName)
 {
     string downLevelName;
     ActiveDs.NameTranslate nt = new ActiveDs.NameTranslate();
     nt.Set(NameTypeUpn, userPrincipalName);
     downLevelName = nt.Get(NameTypeNt4);
     return downLevelName;
 }
 /// <summary>
 /// Convert from a down-level NT4 style name to an Active Directory User Principal Name (UPN).
 /// </summary>
 public static string TranslateDownLevelToUpn(string downLevelNt4Name)
 {
     string userPrincipalName;
     ActiveDs.NameTranslate nt = new ActiveDs.NameTranslate();
     nt.Set(NameTypeNt4, downLevelNt4Name);
     userPrincipalName = nt.Get(NameTypeUpn);
     return userPrincipalName;
 }
        /// <summary>
        /// Convert from an Active Directory User Principal Name (UPN) to a down-level NT4 style name.
        /// </summary>
        public static string TranslateUpnToDownLevel(string userPrincipalName)
        {
            string downLevelName;

            ActiveDs.NameTranslate nt = new ActiveDs.NameTranslate();
            nt.Set(NameTypeUpn, userPrincipalName);
            downLevelName = nt.Get(NameTypeNt4);
            return(downLevelName);
        }
        /// <summary>
        /// Convert from a down-level NT4 style name to an Active Directory User Principal Name (UPN).
        /// </summary>
        public static string TranslateDownLevelToUpn(string downLevelNt4Name)
        {
            string userPrincipalName;

            ActiveDs.NameTranslate nt = new ActiveDs.NameTranslate();
            nt.Set(NameTypeNt4, downLevelNt4Name);
            userPrincipalName = nt.Get(NameTypeUpn);
            return(userPrincipalName);
        }