On the communication between Blue Prism enterprise and Active Directory, must be a good idea to implement what we call "A DC Locator". This feature enforce the Blue Prism Enterprise product to always first try to contact Active Directory controller domains that are in network level close to the application server. Reduce the latency. Improve the Active Directory performances Avoid issues. Below is a code example that can be implemented : $cp = [System.CodeDom.Compiler.CompilerParameters]::new()
Add-Type -Name 'NetApi32' -Namespace 'NativeMethods' -CompilerParameters $cp -MemberDefinition @'
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DOMAIN_CONTROLLER_INFO
{
[MarshalAs(UnmanagedType.LPTStr)]
public string DomainControllerName;
[MarshalAs(UnmanagedType.LPTStr)]
public string DomainControllerAddress;
public uint DomainControllerAddressType;
public Guid DomainGuid;
[MarshalAs(UnmanagedType.LPTStr)]
public string DomainName;
[MarshalAs(UnmanagedType.LPTStr)]
public string DnsForestName;
public uint Flags;
[MarshalAs(UnmanagedType.LPTStr)]
public string DcSiteName;
[MarshalAs(UnmanagedType.LPTStr)]
public string ClientSiteName;
}
[DllImport("Netapi32.dll", CharSet=CharSet.Auto, SetLastError=true)]
static extern int DsGetDcName
(
[MarshalAs(UnmanagedType.LPTStr)]
string ComputerName,
[MarshalAs(UnmanagedType.LPTStr)]
string DomainName,
[In] int DomainGuid,
[MarshalAs(UnmanagedType.LPTStr)]
string SiteName,
[MarshalAs(UnmanagedType.U4)]
DSGETDCNAME_FLAGS flags,
out IntPtr pDOMAIN_CONTROLLER_INFO
);
[DllImport("Netapi32.dll", SetLastError=true)]
static extern int NetApiBufferFree(IntPtr Buffer);
[Flags]
public enum DSGETDCNAME_FLAGS : uint
{
DS_FORCE_REDISCOVERY = 0x00000001,
DS_DIRECTORY_SERVICE_REQUIRED = 0x00000010,
DS_DIRECTORY_SERVICE_PREFERRED = 0x00000020,
DS_GC_SERVER_REQUIRED = 0x00000040,
DS_PDC_REQUIRED = 0x00000080,
DS_BACKGROUND_ONLY = 0x00000100,
DS_IP_REQUIRED = 0x00000200,
DS_KDC_REQUIRED = 0x00000400,
DS_TIMESERV_REQUIRED = 0x00000800,
DS_WRITABLE_REQUIRED = 0x00001000,
DS_GOOD_TIMESERV_PREFERRED = 0x00002000,
DS_AVOID_SELF = 0x00004000,
DS_ONLY_LDAP_NEEDED = 0x00008000,
DS_IS_FLAT_NAME = 0x00010000,
DS_IS_DNS_NAME = 0x00020000,
DS_RETURN_DNS_NAME = 0x40000000,
DS_RETURN_FLAT_NAME = 0x80000000
}
static public DOMAIN_CONTROLLER_INFO GetDomainInfo()
{
const int ERROR_SUCCESS = 0;
IntPtr pDCI = IntPtr.Zero;
int val = DsGetDcName("","",0,"",
DSGETDCNAME_FLAGS.DS_DIRECTORY_SERVICE_REQUIRED|
DSGETDCNAME_FLAGS.DS_RETURN_DNS_NAME|
DSGETDCNAME_FLAGS.DS_IP_REQUIRED, out pDCI);
DOMAIN_CONTROLLER_INFO infos = (DOMAIN_CONTROLLER_INFO)Marshal.PtrToStructure(pDCI, typeof(DOMAIN_CONTROLLER_INFO));
NetApiBufferFree(pDCI);
return infos;
}
'@
[NativeMethods.NetApi32]::GetDomainInfo()
... View more