Active Directory Domain Name for authentication

active-directory

I have a bit of a code that takes an ldap string, a username, and a password, and then attempts to authenticate with the ldap server. The username may or may not contain the domain name, e.g., "DOMAIN\username" or "username" was valid input to this code.

From the ldap string, I will have a clear url, that may look like this LDAP://servername.com/DC=…etc. If I split out the server name portion, I get "servername.com", or "servername.corp", or whatnot. But if I attempt to login with servername.com\username, it does not authenticate. So one option is to split off the last ".", if there is one. Is this valid from an active directory perspective? What happens if there are subdomains such as xyx.servername.com?

I must admit I don't know enough about active directory to answer the above questions, and I can't find documentation that explains them. Some documentation that supports your answer would really help!

Best Answer

When a login is presented as DOMAIN\user, DOMAIN is the NETBIOS name of the AD domain. This is normally the lowest subdomain of the domain, but it can be anything. The other valid way of presenting the name is with a UPN suffix, i.e. user@domain.com. The problem with this is that an administrator can have multiple UPNs in a domain, though the default is the FQDN.

Basically, if you control the AD you should know this. If you don't, then you can't know for sure.