win_domain_user | Directory object not found

Hi Team,

I am trying to create a user in AD with the win_domain_user module but at the time adding the user to groups getting below error,

{
“exception”: “Directory object not found\r\nAt line:280 char:29\r\n+ … ($group in (Get-ADPrincipalGroupMembership -Identity $username @extra …\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : ObjectNotFound: (PatNa9:ADPrincipal) [Get-ADPrincipalGroupMembership], ADIdentityNotFoundException\r\n + FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException,Microsoft.ActiveDirectory.Management.Commands.GetADPrincipalGroupMembership\r\n\r\nScriptStackTrace:\r\nat , : line 280\r\n\r\nMicrosoft.ActiveDirectory.Management.ADIdentityNotFoundException: Directory object not found —> System.ServiceModel.FaultException1[schemas.microsoft.com._2008._1.ActiveDirectory.CustomActions.GetADPrincipalGroupMembershipFault]: Active Directory returned an error processing the operation.\r\n\r\nServer stack trace: \r\n at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)\r\n at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)\r\n at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)\r\n at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)\r\n\r\nException rethrown at [0]: \r\n at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)\r\n at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)\r\n at schemas.microsoft.com._2008._1.ActiveDirectory.CustomActions.AccountManagement.GetADPrincipalGroupMembership(GetADPrincipalGroupMembershipRequest request)\r\n at Microsoft.ActiveDirectory.Management.AdwsConnection.GetADPrincipalGroupMembership(GetADPrincipalGroupMembershipRequest request)\r\n --- End of inner exception stack trace ---\r\n at Microsoft.ActiveDirectory.Management.AdwsConnection.ThrowExceptionForExtendedError(String extendedErrorMessage, Exception innerException)\r\n at Microsoft.ActiveDirectory.Management.AdwsConnection.ThrowExceptionForErrorCode(String message, String errorCode, String extendedErrorMessage, Exception innerException)\r\n at Microsoft.ActiveDirectory.Management.AdwsConnection.ThrowException(CustomActionFault caFault, FaultException faultException)\r\n at Microsoft.ActiveDirectory.Management.AdwsConnection.GetADPrincipalGroupMembership(GetADPrincipalGroupMembershipRequest request)\r\n at Microsoft.ActiveDirectory.Management.ADWebServiceStoreAccess.Microsoft.ActiveDirectory.Management.IADAccountManagement.GetADPrincipalGroupMembership(ADSessionHandle handle, GetADPrincipalGroupMembershipRequest request)\r\n at Microsoft.ActiveDirectory.Management.ADAccountManagement.GetPrincipalGroupMembership(String partitionDN, String principalDN, String resourceContextServer, String resourceContextPartition)\r\n at Microsoft.ActiveDirectory.Management.Commands.GetADPrincipalGroupMembership.GetGroupMembershipProcessCSRoutine()\r\n at Microsoft.ActiveDirectory.Management.CmdletSubroutinePipeline.Invoke()\r\n at Microsoft.ActiveDirectory.Management.Commands.ADCmdletBase1.ProcessRecord()”,
“msg”: “Unhandled exception while executing module: Directory object not found”,
“_ansible_no_log”: false,
“changed”: false,
“item”: [
“GLB-GS-SOL-SpecOps-Password-Policy-Group”,
“GLB-GS-SOL-DUOSYNC”,
“GLB-GS-SOL-SERVICEDESK”
],
“ansible_loop_var”: “item”,
“_ansible_item_label”: [
“GLB-GS-SOL-SpecOps-Password-Policy-Group”,
“GLB-GS-SOL-DUOSYNC”,
“GLB-GS-SOL-SERVICEDESK”
]
}

Can you please help me where I’m doing wrong?

Thank you in advance,
Mani Kumar