question

RevkovStanislav-4638 avatar image
0 Votes"
RevkovStanislav-4638 asked ·

to get current hostname or IP of LDAP

Hi,

is that possible to get current hostname or IP of LDAP using by an application on the MS Server 2016?
Sometimes one of the LDPA is down and application stops authentication and workaround is only clearing of DNS cache ipconfig /flushdns.
I need to create a Power Shell for that, but I have no idea how to set variable with the name or IP address of the existing using LDAP server.
Can you help please?

windows-server-powershellwindows-dhcp-dns
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RevkovStanislav-4638 avatar image
0 Votes"
RevkovStanislav-4638 answered ·

Thank you everyone to reply. I confused with LDAP and AD servers. Finaly the application works with AD server, but not LDAP.

I needed to clear DNS cache on the application server and checked if the new AD in DNS cache is available.
I created the next PowerShell script and scheduled it in the TaskScheduler every 15 mins. May be it will helpful to someone:

for($i = 0; $i -le 4; $i++){ipconfig /flushdns
if(Test-Connection -ComputerName <YourDomain> -Quiet) {break}}

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered ·

Clear-DnsClientCache is the PowerShell equivalent of "ipconfig /flushdns"

Is the machine on which you want to clear the cache the LDAP server or is it on a machine that uses the LDAP server? Neither "ipconfig /flushdns" nor Clear-DnsClientCache take any parameters, so it isn't clear why you want to get the IP address (or name) into a variable.

How do you discover which machine needs to have its DNS cache cleared now? And how do you propose to execute a PowerShell script on the target machine?

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SunnyQi-MSFT avatar image
0 Votes"
SunnyQi-MSFT answered ·

Hi,

Thanks for posting in Q&A platform.

Please try if nslookup -type=srv _ldap._tcp.DOMAINNAME or nslookup -query=srv _ldap._tcp.DOMAINNAME can help you.

Best Regards,
Sunny


If the Answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.