-
Notifications
You must be signed in to change notification settings - Fork 53
Group: Unable to add Different forest User to Local Group #82
Comments
Apologies, I realized that was was using the builtin Group Resource and not the version from this page, I have since updated but unfortunately continue to get a failure. I am running Version 2.8.0.0 of the PSDSCResource Module with PowerShell 5.1 on Windows Server 2012 R2. Unfortunately there are 2 unresolved SIDs already in the Administrators group, the Test and Set Methods successfully flag these with a warning. The DomainB Group member is also successfully resolved according to the verbose output. The error message I get is: My guess is that the set command is attempting to re-add the unknown SIDs in which is failing. Is it possible to update to allow this scenario to work please? |
I had this issue
I fixed it by using "domain\username" format when login for "Credential" parameter. |
To do further testing I have set up a lab environment with A domain controller and a separate VM in each DomainA.Local and DomainB.Local. On DomainA-VM-01 I ran the following configuration:
When the GroupName was set to localgroup (which was a specific local group I created) the operation succeeded however when setting GroupName to Administrators the operation failed with the following message:
I can manually add the user into the administrators group and when I do the test resource completes successfully. Looking at the code it appears that the actual add command is failing which is here To assist with debugging I added the following lines just above the add command:
You can see in the verbose output above that the user was successfully resolved from DomainB\DomainB-User1 to Domain B User 1 which is the user's full name. |
I apologize for the long delayed reply. The reason you are seeing the first error (at least) is because when you run the configuration, DSC runs Test-DscConfiguration. If you have members to include or members to exclude as part of the config, then DSC must iterate through the members of the Group to check if the indicated members are present/absent to test if the node is in the desired state. To compare the members accurately, the Group resource attempts to get the SIDs of each user in the group to compare, if there are any issues getting the SIDs of any of the members or if the user running the command doesn't have permissions to access all of the user information in the group, then you're going to get an error before Set-DscConfiguration even runs. When you manually add the users you're not doing any test to see if the user already exists in the group so the operation succeeds. I'm not sure about the second error that you're seeing though. What exactly is different about the nature of the two different groups you are testing with? |
@ld0614 Thanks for the detailed configuration and verbose output. I label this as a 'bug' and 'help wanted' so anyone in the community can run with this issue. |
Fix Get-ModuleScriptResourceNames - Fixes PowerShell#81
Hello, First some observations. Assuming I have myDomain.local and foreignDomain.local and the computer I am running the resource on belongs to myDomain. Domains have trust relationships established, obviously.
This works successfully. Moreover, in the verbose output it can be seen that security principals are successfully resolved from local SAM database, myDomain and foreignDomain. Now lets make state of the group following:
This also succeeds. This is important, above two cases prove that resource can work with foreign accounts and is able to use domain trusts successfully.
Literally any attempts to run resource against group which already has security principals from other domain fails. Specifying Credentials parameter does nothing. Substituting users with groups does nothing. Examining $PrincipalContextCache and verbose logs proves that security principals are resolved successfully, that domain trusts do work, that $PrincipalContext and $PrincipalContextCache are exactly the same as in the cases where accounts were added successfully.
It appears like a bug in underlying .net classes and no matter how I struggled, I couldn't make The solutions I see at the moment are:
I tested this third approach in my environment and it works great, however I would like to hear opinion from more experienced colleagues about it. Also, more careful checks might be required to validate if we indeed hit this issue rather than simply catching all exceptions. Looking forward to hearing from maintainers to finally get this issue resolved. |
@SDedik - That looks like a good workaround to the problem. I'd love to see you put a Pull Request in for it. I'll go ahead and review it as soon as I'm notified. |
@Sudman1, PR has been created. Please have a look. I'm not sure if any kind of automated tests can be developed for this kind of problem because it heavily depends on external infrastructure layout, therefore I made the PR without any additional tests. |
I am running the following resource
Group AddUser
{
GroupName = "Administrators"
MembersToInclude = @("DOMAINB\USER1")
Credential = $DomainBCredential
Ensure = 'Present'
}
There are two forests with a single domain each, Computer1 is in domainA and user1 is in domainB. There is a full trust relationship between domains, it should be noted that NETBIOS name is not the same as FQDN on either forest.
I am attempting to add User1 to the local administrators group on Computer1. It should be noted that a number of additional users from domainA are already added into the Computer1 administrative user group via Group Policy, there are also a number of orphaned SIDs. This operation succeeds if done manually.
The credential is to another account on DomainB and has domain admin rights. When running the code I get the following error:
VERBOSE: [COMPUTERNAME]: [[Group]AddUser] Resolving DOMAINB in the Domain Admins domain.
Exception calling "FindByIdentity" with "3" argument(s): "The user name or password is
incorrect.
"
+ CategoryInfo : NotSpecified: (:) [], CimException
+ FullyQualifiedErrorId : COMException,ResolveSidToPrincipal
+ PSComputerName : COMPUTERNAME.DOMAINA.com
When running the exact same configuration using the xGroup resource the configuration resolves and runs correctly. All parameters where kept in memory so the actual username and password couldn't have had a typo. Unfortunately there is a secondary issue with xGroup which I'll post separately.
The text was updated successfully, but these errors were encountered: