Click here to Skip to main content
15,887,293 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi all,

By making use of .NET classes, how can I accomplish the following nslookup command without making use of the command prompt window:

MSIL
C:\Users\userA>nslookup
Default Server:  server.domain.local
Address:  192.168.0.1
> set type=srv
> _ldap._tcp.domain.local
Server:  server.domain.local
Address:  192.168.0.1
_ldap._tcp.domain.local  SRV service location:
          priority       = 1
          weight         = 1
          port           = 0
          svr hostname   = requiredServerName.domain.local
requiredServerName.domain.local  internet address = 192.168.0.2
>


Many thanks in advance.
Kind regards,
Posted
Updated 6-May-16 23:19pm
v4

The examples on this[^] page should give you the idea.
 
Share this answer
 
Hi all,

This is how to do it:

Download the following assembly from CodePlex: DnDns and PocketDnDns - A .NET DNS Client Resolver Library[^]

Implement the following piece of code (DnsQueryResponse contains all the desired information):

DnsQueryRequest request = new DnsQueryRequest();
            DnsQueryResponse response = request.Resolve("192.168.0.1", "_ldap._tcp.domain.local", DnDns.Enums.NsType.SRV, DnDns.Enums.NsClass.ANY, System.Net.Sockets.ProtocolType.Tcp);


Kind regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900