The DsGetDcName function returns the name of a domain controller in a specified domain.
The DsGetDcName function returns the name of a domain controller in a specified domain. This function accepts additional domain controller selection criteria to indicate preference for a domain controller with particular characteristics.
<Binary Id="ActiveDirectory" SourceFile="$(var.BinDir)\ActiveDirectory.dll" />
<CustomAction Id="SetDSFlags" Property="DS_FLAGS" Value="DS_IP_REQUIRED|DS_ONLY_LDAP_NEEDED|DS_RETURN_DNS_NAME" />
<CustomAction Id="FindActiveDirectory" BinaryKey="ActiveDirectory" DllEntry="DirectoryGetDcName" Execute="immediate" Return="check" />
<CustomAction Id="SetActiveDirectoryProperty" Property="ACTIVE_DIRECTORY_SERVER_DISPLAYED" Value="[DS_DOMAINCONTROLLER_NAME]" />
<InstallUISequence>
<Custom Action="SetDSFlags" After="CostInitialize">1</Custom>
<Custom Action="FindActiveDirectory" After="SetDSFlags">1</Custom>
<Custom Action="SetActiveDirectoryProperty" After="FindActiveDirectory">1</Custom>
</InstallUISequence>