Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,11 @@ public void TestUserCredentialsPropertiesOnWindows()
{
p = CreateProcessLong();

// ensure the new user can access the .exe (otherwise you get Access is denied exception)
SetAccessControl(username, p.StartInfo.FileName, add: true);
if (PlatformDetection.IsNotWindowsServerCore) // for this particular Windows version it fails with Attempted to perform an unauthorized operation (#46619)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is still valid without this? If the test succeeds without this on Windows Server Core, why is it needed on other Windows?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added this recently when I was working on re-enabling this test and it was mandatory on my machine to make it work (#46083)

I have no idea why it does not work on machines from this certain pool. Is it a thing related to Windows Server? Some custom helix machine setup?

The test is restricted to admin accounts only:

[ConditionalFact(nameof(IsAdmin_IsNotNano_RemoteExecutorIsSupported))] // Nano has no "netapi32.dll", Admin rights are required

private static bool IsAdmin_IsNotNano_RemoteExecutorIsSupported
=> PlatformDetection.IsWindowsAndElevated && PlatformDetection.IsNotWindowsNanoServer && RemoteExecutor.IsSupported;

Which makes it even more confusing (I would assume that Admin accounts which can create other user accounts can also add permissions to files?)

{
// ensure the new user can access the .exe (otherwise you get Access is denied exception)
SetAccessControl(username, p.StartInfo.FileName, add: true);
}

p.StartInfo.LoadUserProfile = true;
p.StartInfo.UserName = username;
Expand All @@ -500,10 +503,6 @@ public void TestUserCredentialsPropertiesOnWindows()
}
finally
{
SetAccessControl(username, p.StartInfo.FileName, add: false); // remove the access

Assert.Equal(Interop.ExitCodes.NERR_Success, Interop.NetUserDel(null, username));

if (handle != null)
handle.Dispose();

Expand All @@ -513,6 +512,13 @@ public void TestUserCredentialsPropertiesOnWindows()

Assert.True(p.WaitForExit(WaitInMS));
}

if (PlatformDetection.IsNotWindowsServerCore)
{
SetAccessControl(username, p.StartInfo.FileName, add: false); // remove the access
}

Assert.Equal(Interop.ExitCodes.NERR_Success, Interop.NetUserDel(null, username));
}
}

Expand Down