How can I tell which Domain controller I'm authenticated to?

64

22

How can I tell which Domain controller I'm authenticated to? Is there a way to do this without local admin?

C. Ross

Posted 2011-09-09T12:55:11.827

Reputation: 5 284

Answers

96

You can find this through the following command:

echo %LOGONSERVER%

And you don't have to be admin or poweruser to use it. Have a look at the output of this command:

set

Shadok

Posted 2011-09-09T12:55:11.827

Reputation: 3 760

2FYI: Powershell didn't seem to have that variable set. I had to run it from basic command shell. – Christian Bongiorno – 2015-07-01T21:42:39.827

This doesn't work when you're logged on as a local user and you're interested in how the computer is authenticated to the domain. For that, see the other answer referencing nltest. – wfaulk – 2016-04-01T19:47:03.590

A note, here you get your logged in users controller. Not the domain controller of the computer. – leiflundgren – 2016-06-09T09:22:57.563

1@ChristianBongiorno It works with powershell: it is a simple call on an environment variable. With cmd, these calls are made by %variable%, in Powershell you need another syntax: $env:variable. So in this case, type in Powershell: $env:Logonserver, and you get the same result. – Tobias – 2016-07-05T07:36:48.577

47

To determine computer / server DC use NLTEST:

nltest /dsgetdc:<domain_name> 

To list all DC's with their appropriate site, try:

nltest /dclist:<domain_name>

You don't have to use the FQDN of the domain name or server -- for example, instead of saying /dclist:services.microsoft.com, you can simply type /dclist:services (as long as you are an authenticated member of that domain, of course).

For user authentication and group policy use LOGONSERVER variable:

echo %logonserver%

Michael Knox

Posted 2011-09-09T12:55:11.827

Reputation: 471

nltest was much more reliable for me because LOGONSERVER did not work when coming by RDP – ZoolWay – 2015-11-26T09:39:29.733

4

set l will respond with the variables for both localappdata and for logonserver. However, logonserver is the only variable you are interested in, and the one which will tell you the name of the domain controller you authenticated against.

To only get the logonserver information, type set log (which is simply an abbreviation of set logonserver). The name of the domain controller you authenticated against will be returned.

Noel

Posted 2011-09-09T12:55:11.827

Reputation: 41

3

This only answers your question if you have Outlook:

I found an interesting feature in Outlook. If you hold Ctrl and right click the icon in the task bar then click connection status it shows you the exchange server your connected to as well as what domain controller you are connected to. I actually found that one answering another question about Exchange connections, great way to recycle answers...

Supercereal

Posted 2011-09-09T12:55:11.827

Reputation: 8 643

1I agree that this is less than reliable for the OP's question, but it is still useful info. Thanks! – jpaugh – 2016-04-06T15:38:54.310

This is NOT entirely correct. In the rare situation where you have 2 DC's on site for DIFFERENT domains which both belong to the same forest and which both carry the Directory services, it is possible that you authenticate to your own domains DC while Outlook uses the other DC for the directory services. I have seen this happen. Caused a lot of grief, because adding delegates in Outlook doesn't work properly if your logon DC and the directory server used by Outlook are not in the same domain. – Tonny – 2013-08-26T10:16:02.117

1

Powershell provides (with no parameters):

Get-ADDomainController

Or specifically:

(Get-ADDomainController).HostName

rupert160

Posted 2011-09-09T12:55:11.827

Reputation: 137

1

set L lists all environment variables that begin with the letter L

Erwin

Posted 2011-09-09T12:55:11.827

Reputation: 11

1Mind explaining what this does? – soandos – 2012-07-15T18:18:11.483

Seems like it lists all variables starting with the letter L. Try set a for example. – Peter Jaric – 2012-11-22T18:30:44.723