コード例 #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));
        }
コード例 #2
0
 public void GetCurrentUserNameWithoutDomainTest()
 {
     string[] splits = WindowsIdentity.GetCurrent().Name.Split('\\');
     Assert.IsTrue(splits.Length > 1);
     Assert.AreEqual(splits[splits.Length - 1], WinUtils.GetCurrentUserNameWithoutDomain());
 }
コード例 #3
0
 public void GetCurrentUserNameTest()
 {
     Assert.AreEqual(WindowsIdentity.GetCurrent().Name, WinUtils.GetCurrentUserName());
 }