Exemplo n.º 1
0
        /// <summary>
        /// Get the current user email address
        /// </summary>
        /// <returns></returns>
        public static string CurrentUserEmailAddress()
        {
            var userPrincipal = WinUtils.GetPrincipal() as UserPrincipal;

            if (userPrincipal != null)
            {
                if (userPrincipal.EmailAddress != null && userPrincipal.EmailAddress.Length > 0)
                {
                    return(userPrincipal.EmailAddress);
                }
            }
            var username = WinUtils.GetCurrentUserNameWithoutDomain();
            var domain   = IPGlobalProperties.GetIPGlobalProperties();

            return(string.Format("{0}@{1}.{2}", username, domain.HostName, domain.DomainName));
        }
Exemplo n.º 2
0
 public void GetCurrentUserNameWithoutDomainTest()
 {
     string[] splits = WindowsIdentity.GetCurrent().Name.Split('\\');
     Assert.IsTrue(splits.Length > 1);
     Assert.AreEqual(splits[splits.Length - 1], WinUtils.GetCurrentUserNameWithoutDomain());
 }