You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The win_domain_user task should return with an ok result suggesting that the user account already exists.
ACTUAL RESULTS
TASK [Create service users] **********************************************************************************************************************************
task path: <redacted>
Using module file /home/jimspeir/.ansible/collections/ansible_collections/community/windows/plugins/modules/win_domain_user.ps1
Pipelining is enabled.
<redacted>> ESTABLISH WINRM CONNECTION FOR USER: <redacted> on PORT 5985 TO <redacted>
EXEC (via pipeline wrapper)
The full traceback is:
An attempt was made to add an object to the directory with a name that is already in use
At line:170 char:21
+ ... $user_obj = New-ADUser @create_args -WhatIf:$check_mode -PassThru @ex ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (CN=Redgate SQL ...enant222,dc=com:String) [New-ADUser], ADException
+ FullyQualifiedErrorId : ActiveDirectoryServer:8305,Microsoft.ActiveDirectory.Management.Commands.NewADUser
ScriptStackTrace:
at <ScriptBlock>, <No file>: line 170
Microsoft.ActiveDirectory.Management.ADException: An attempt was made to add an object to the directory with a name that is already in use ---> System.ServiceModel.FaultException: The supplied entry already exists.
--- End of inner exception stack trace ---
at Microsoft.ActiveDirectory.Management.AdwsConnection.ThrowExceptionForExtendedError(String extendedErrorMessage, Exception innerException)
at Microsoft.ActiveDirectory.Management.AdwsConnection.ThrowExceptionForErrorCode(String message, String errorCode, String extendedErrorMessage, Exception innerException)
at Microsoft.ActiveDirectory.Management.AdwsConnection.ThrowExceptionForFaultDetail(FaultDetail faultDetail, FaultException faultException)
at Microsoft.ActiveDirectory.Management.AdwsConnection.ThrowException(AdwsFault adwsFault, FaultException faultException)
at Microsoft.ActiveDirectory.Management.AdwsConnection.Create(ADAddRequest request)
at Microsoft.ActiveDirectory.Management.ADWebServiceStoreAccess.Microsoft.ActiveDirectory.Management.IADSyncOperations.Add(ADSessionHandle handle, ADAddRequest request)
at Microsoft.ActiveDirectory.Management.ADActiveObject.Create()
at Microsoft.ActiveDirectory.Management.Commands.ADNewCmdletBase`3.ADNewCmdletBaseProcessCSRoutine()
at Microsoft.ActiveDirectory.Management.CmdletSubroutinePipeline.Invoke()
at Microsoft.ActiveDirectory.Management.Commands.ADCmdletBase`1.ProcessRecord()
failed: [<redacted>] (item={'name': 'Redgate SQL Monitor', 'username': 'sql.monitor', 'description': 'Test', 'password': 'testp@55word!'}) => {
"ansible_loop_var": "item",
"changed": false,
"item": {
"description": "Test",
"name": "Redgate SQL Monitor",
"password": "testp@55word!",
"username": "sql.monitor"
},
"msg": "Unhandled exception while executing module: An attempt was made to add an object to the directory with a name that is already in use"
}
The text was updated successfully, but these errors were encountered:
Or to $null if this command raises an ADIdentityNotFoundException. The problem, therefore, is that the $identity variable in my case is set to the name parameter, in my case Redgate SQL Monitor, as opposed to the sam_account_name parameter, which should have been sql.monitor but in the playbook I don't pass it in (!).
If I instead set the identity parameter to the sam_account_name property, then the Get-ADUser cmdlet runs as expected and returns the user properly.
Therefore, I think the best method here is to look to amend the default for the identity on line 90:
SUMMARY
If the user already exists and you try to create them, the ps1 errors during the
New-User
call on line 180:community.windows/plugins/modules/win_domain_user.ps1
Line 180 in 72d3bd0
I suspect that if check_mode was enabled, no error would not occur here.
ISSUE TYPE
COMPONENT NAME
community.windows.win_domain_user
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Target is a Windows 2019 Standard box, source is an Ubuntu 20.04.3 box. These are on the same virutal switch.
STEPS TO REPRODUCE
EXPECTED RESULTS
The win_domain_user task should return with an
ok
result suggesting that the user account already exists.ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: