Пример #1
0
        public SafeTokenHandle DoLogon(IActivityIOPath path)
        {
            var lpszUsername = OperationsHelper.ExtractUserName(path);
            var lpszDomain   = OperationsHelper.ExtractDomain(path);
            var lpszPassword = path.Password;
            var lpszPath     = path.Path;

            try
            {
                var loggedOn = _loginApi.LogonUser(lpszUsername, lpszDomain, lpszPassword, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, out SafeTokenHandle safeToken);
                if (loggedOn)
                {
                    return(safeToken);
                }
                loggedOn = _loginApi.LogonUser(lpszUsername, lpszDomain, lpszPassword, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_WINNT50, out SafeTokenHandle safeTokenHandle);
                if (loggedOn)
                {
                    return(safeTokenHandle);
                }
            }

            catch (Exception ex)
            {
                Dev2Logger.Error(ex.Message, ex, GlobalConstants.WarewolfError);
            }
            finally
            {
                var ex = Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error());
                Dev2Logger.Info(ex.Message, GlobalConstants.Warewolf);
            }
            throw new Exception(string.Format(ErrorResource.FailedToAuthenticateUser, lpszUsername, lpszPath));
        }
Пример #2
0
        public void OperationsHelper_ExtractDomain()
        {
            const string userName           = "******";
            const string expectedUserName   = "";
            var          mockActivityIOPath = new Mock <IActivityIOPath>();

            mockActivityIOPath.Setup(activityIOPath => activityIOPath.Username).Returns(userName);
            var operationsHelper = OperationsHelper.ExtractDomain(mockActivityIOPath.Object);

            Assert.AreEqual(expectedUserName, operationsHelper);
        }
Пример #3
0
 public void OperationsHelper_ExtractDomain_ExpectedException()
 {
     OperationsHelper.ExtractDomain(null);
 }