Esempio n. 1
0
        void DeletedUserCannotBeLocated()
        {
            manager.CreateUser(testUserName);
            manager.DeleteUser(testUserName);

            Assert.True(string.IsNullOrEmpty(manager.FindUser(testUserName)));
        }
 public ImpersonationProcessRunnerTests(ITestOutputHelper helper)
 {
     logger   = helper;
     username = GenerateRandomAlphaString();
     helper.WriteLine(username);
     userManager = new LocalPrincipalManager("IIS_IUSRS");
     userManager.DeleteUser(username);
     creds = userManager.CreateUser(username);
 }
Esempio n. 3
0
            public async Task WhenCredentialsGiven_LoadsUserEnvironment()
            {
                var desktopPermissionManager  = new DesktopPermissionManager();
                LocalPrincipalManager manager = new LocalPrincipalManager(desktopPermissionManager, "IIS_IUSRS");

                string userName = "******";

                if (manager.FindUser(userName) != null)
                {
                    manager.DeleteUser(userName);
                }
                var user = manager.CreateUser(userName);

                desktopPermissionManager.AddDesktopPermission(userName);

                try
                {
                    var si = CreateRunSpec("cmd.exe", new[] { "/C", "set USERNAME" });
                    si.Credentials         = user;
                    si.BufferedInputOutput = true;
                    si.WorkingDirectory    = Environment.SystemDirectory;

                    using (var p = Runner.Run(si))
                    {
                        WaitForGoodExit(p, 1000);

                        var output = await p.StandardOutput.ReadToEndAsync();

                        string expectedUserName = string.Format("USERNAME={0}", user.UserName);
                        Assert.Contains(expectedUserName, output);
                    }
                }
                finally
                {
                    desktopPermissionManager.RemoveDesktopPermission(userName);
                    manager.DeleteUser(userName);
                }
            }
 public void Dispose()
 {
     userManager.DeleteUser(username);
 }
 public ImpersonationProcessRunnerTests()
 {
     userManager = new LocalPrincipalManager("IIS_IUSRS");
        userManager.DeleteUser(username);
        creds = userManager.CreateUser(username);
 }
Esempio n. 6
0
 public ImpersonationProcessRunnerTests()
 {
     userManager = new LocalPrincipalManager("IIS_IUSRS");
     userManager.DeleteUser(username);
     creds = userManager.CreateUser(username);
 }