473,385 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Get the servername of the Domain Controller

Ben
Hi

Is there any way to retrieve the name of the DC that a client has logged
onto in VB .NET?

Thanks
B
Jun 8 '07 #1
1 7226
Ben,

You have a couple options.

You could use PInvoke for the following signature:
Private Declare Function NetGetDCName Lib "netapi32.dll" (ByVal
strServerName As Object, ByVal strDomainName As Object, ByVal pBuffer As
Long) As Long
You could use the System.Net namespace:

Dim MYIP As System.Net.IPHostEntry =
System.Net.Dns.GetHostEntry(My.Computer.Name)
Dim IPaddress As String = MYIP.AddressList.GetValue(0).ToString
Console.WriteLine(System.Net.Dns.GetHostEntry(IPad dress).HostName)
You could also use the System.Net.NetworkInformation namespace for the long
way around, but more detail. Check out this code:

Imports System.Net
Imports System.Net.NetworkInformation

Public Class NetworkInfo
Public Shared Sub ShowIPAddresses()
Dim computerProperties As IPGlobalProperties =
IPGlobalProperties.GetIPGlobalProperties()
Dim nics() As NetworkInterface =
NetworkInterface.GetAllNetworkInterfaces()
Console.WriteLine("Interface information for {0}.{1} ", _
computerProperties.HostName, computerProperties.DomainName)
If (nics Is Nothing OrElse nics.Length < 1) Then
Console.WriteLine(" No network interfaces found.")
Return
End If

Console.WriteLine(" Number of interfaces .................... :
{0}", nics.Length)
For Each adapter As NetworkInterface In nics
Dim adapterProperties As IPInterfaceProperties =
adapter.GetIPProperties()
Dim dnsServers As IPAddressCollection =
adapterProperties.DnsAddresses

If (Not dnsServers Is Nothing) Then
For Each dns As IPAddress In dnsServers
Console.WriteLine(" DNS Servers
.............................. : {0}", dns.ToString())
Console.WriteLine(" Server Name
........................... : {0}",
System.Net.Dns.GetHostEntry(dns.ToString).HostName )
Next
End If
Next
End Sub
End Class
You could also use the registry:
http://www.java2s.com/Code/CSharp/Ne...DNSServers.htm

Hope this helps,
Steve

"Ben" <Be*@Newsgroups.microsoft.comwrote in message
news:uc**************@TK2MSFTNGP02.phx.gbl...
Hi

Is there any way to retrieve the name of the DC that a client has logged
onto in VB .NET?

Thanks
B

Jun 9 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Frank | last post by:
I have observed that a temporary loss of a domain controller can cause problems creating new ado connections between a client machine running ado and a separate sql server machine that are members...
1
by: SL | last post by:
How do I set up access to a file on a Windows Server 2003 Domain Controller that also has IIS? The file sits on another server. The Domain Controller / IIS server connects to this file through a...
1
by: cksanjose | last post by:
We have a web server that is hosting several ASP.Net-based websites (intranet). The server was promoted as a backup domain controller. After doing this, the websites are not working anymore....
0
by: bi89101 | last post by:
I'm trying to debug a C++ application on the local machine (not ASP.NET) which happens to be a domain controller. Administrators can debug, but domain users cannot. I have looked at the debugger...
0
by: Rob Roberts | last post by:
I have developed an ASP.NET 2.0 application using localhost on my Windows XP workstation, and it all works fine there. I tried to copy it to my test web server, which is a domain controller...
0
by: Wasco | last post by:
Hi all, I have a little problem.. I need to create a class that perform: - retrieve all users whitin a domain in domain controller (domainName is input parameter) - verify if a user is whitin...
0
by: Wasco | last post by:
Hi all, I have a little problem.. I need to create a class that perform: - retrieve all users whitin a domain in domain controller (domainName is input parameter) - verify if a user is whitin...
3
by: rabselling | last post by:
Hello everyone, I have a domain where there in the network,140 computers working. When ever the new computer come and want to have network, i make a connection with the domain and i give every...
4
by: Leo | last post by:
Hi, guys. I want to use c# to get the privilege of a domain controller in a non-DC machine as i have the user name and password of DC. But i can't find any functions in MSDN. Has anyone met the...
0
by: SandVich | last post by:
i had two servers with Windows2000 Advance server OS. One is main Domain Controller and second on is additional. A problem occurred in additional domain controller and ultimately i had to format...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.