Discussion:
Find fully qualified domain name
(too old to reply)
Jurgen
2004-11-22 10:33:39 UTC
Permalink
Is there any way that from a Windows XP client that is part of the
domain you can findout the fully qualified Active Directory name like
test.com?

Thanks,
KevM
2004-11-22 14:37:35 UTC
Permalink
Hi,

From a commandline type set USERDNSNAME should give you the FQDN

Kev
Post by Jurgen
Is there any way that from a Windows XP client that is part of the
domain you can findout the fully qualified Active Directory name like
test.com?
Thanks,
Richard Mueller [MVP]
2004-11-22 14:41:08 UTC
Permalink
Post by Jurgen
Is there any way that from a Windows XP client that is part of the
domain you can findout the fully qualified Active Directory name like
test.com?
Hi,

1. The environment variable USERDNSDOMAIN.

2. The DomainDNSName property of the ADSystemInfo object.

3. The DefaultNamingContext property of the RootDSE object.

4. You can retrieve the NetBIOS name of the domain (in various ways) and use
the NameTranslate object to convert to the DNS domain name.

How you do this depends on what language/platform you are using. Reply if
you want VBScript examples.
--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--
Jurgen Postelmans
2004-11-22 19:01:52 UTC
Permalink
Richard,

I plan to do this from C# code. But any example will do as I do not have
much experience with ADSI programming...
Post by Richard Mueller [MVP]
Post by Jurgen
Is there any way that from a Windows XP client that is part of the
domain you can findout the fully qualified Active Directory name like
test.com?
Hi,
1. The environment variable USERDNSDOMAIN.
2. The DomainDNSName property of the ADSystemInfo object.
3. The DefaultNamingContext property of the RootDSE object.
4. You can retrieve the NetBIOS name of the domain (in various ways) and use
the NameTranslate object to convert to the DNS domain name.
How you do this depends on what language/platform you are using. Reply if
you want VBScript examples.
--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--
Joe Kaplan (MVP - ADSI)
2004-11-22 20:33:59 UTC
Permalink
This is an example of the RootDSE approach in C#:

DirectoryEntry de;
string dnsHostName;
using (de)
{
de = new DirectoryEntry("RootDSE");
dnsHostName = (string) de.Properties["dnsHostName"].Value;
}

Joe K.
Post by Jurgen Postelmans
Richard,
I plan to do this from C# code. But any example will do as I do not have
much experience with ADSI programming...
Post by Richard Mueller [MVP]
Post by Jurgen
Is there any way that from a Windows XP client that is part of the
domain you can findout the fully qualified Active Directory name like
test.com?
Hi,
1. The environment variable USERDNSDOMAIN.
2. The DomainDNSName property of the ADSystemInfo object.
3. The DefaultNamingContext property of the RootDSE object.
4. You can retrieve the NetBIOS name of the domain (in various ways) and use
the NameTranslate object to convert to the DNS domain name.
How you do this depends on what language/platform you are using. Reply if
you want VBScript examples.
--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--
Jurgen Postelmans
2004-11-22 21:48:31 UTC
Permalink
Hi,

dnsHostName returns the full name of the server(like servername.domain.com).
What I'm looking for is domain.com.
I'm unsure whether I can just extract the domain name from the dnsHostName?
Is the servername always before the first dot? Isn't there a property in AD
that gives me immediatly the qualified domain name?
Post by Joe Kaplan (MVP - ADSI)
DirectoryEntry de;
string dnsHostName;
using (de)
{
de = new DirectoryEntry("RootDSE");
dnsHostName = (string) de.Properties["dnsHostName"].Value;
}
Joe K.
Post by Jurgen Postelmans
Richard,
I plan to do this from C# code. But any example will do as I do not have
much experience with ADSI programming...
Post by Richard Mueller [MVP]
Post by Jurgen
Is there any way that from a Windows XP client that is part of the
domain you can findout the fully qualified Active Directory name like
test.com?
Hi,
1. The environment variable USERDNSDOMAIN.
2. The DomainDNSName property of the ADSystemInfo object.
3. The DefaultNamingContext property of the RootDSE object.
4. You can retrieve the NetBIOS name of the domain (in various ways) and use
the NameTranslate object to convert to the DNS domain name.
How you do this depends on what language/platform you are using. Reply if
you want VBScript examples.
--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--
Richard Mueller [MVP]
2004-11-22 22:22:17 UTC
Permalink
Hi,

Use the "DefaultNamingContext" property of the RootDSE object.

Note there are two formats for the DNS domain name. For example:

MyCompany.MyDomain.com
DC=MyCompany,DC=MyDomain,DC=com

dnsHostName returns a name similar to the first example above,
DefaultNamingContext returns a name similar to the second.

The environment variable and ADSystemInfo return the DNS domain name similar
to the first example. If you use NameTranslate to convert the NetBIOS domain
name to the DNS domain name, it looks like the second example.
--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--
Post by Jurgen Postelmans
Hi,
dnsHostName returns the full name of the server(like
servername.domain.com).
Post by Jurgen Postelmans
What I'm looking for is domain.com.
I'm unsure whether I can just extract the domain name from the
dnsHostName?
Post by Jurgen Postelmans
Is the servername always before the first dot? Isn't there a property in AD
that gives me immediatly the qualified domain name?
Post by Joe Kaplan (MVP - ADSI)
DirectoryEntry de;
string dnsHostName;
using (de)
{
de = new DirectoryEntry("RootDSE");
dnsHostName = (string) de.Properties["dnsHostName"].Value;
}
Joe K.
Post by Jurgen Postelmans
Richard,
I plan to do this from C# code. But any example will do as I do not have
much experience with ADSI programming...
Post by Richard Mueller [MVP]
Post by Jurgen
Is there any way that from a Windows XP client that is part of the
domain you can findout the fully qualified Active Directory name like
test.com?
Hi,
1. The environment variable USERDNSDOMAIN.
2. The DomainDNSName property of the ADSystemInfo object.
3. The DefaultNamingContext property of the RootDSE object.
4. You can retrieve the NetBIOS name of the domain (in various ways)
and
Post by Jurgen Postelmans
Post by Joe Kaplan (MVP - ADSI)
Post by Jurgen Postelmans
Post by Richard Mueller [MVP]
use
the NameTranslate object to convert to the DNS domain name.
How you do this depends on what language/platform you are using. Reply if
you want VBScript examples.
--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--
Joe Kaplan (MVP - ADSI)
2004-11-22 23:10:15 UTC
Permalink
I think the official way to do this would be to take the
defaultNamingContext value from RootDSE and do a search in the configuration
container (from configurationNamingContext in RootDSE) for the crossRef
object whose nCName matches the defaultNamingContext. From that object, you
would get its dnsRoot attribute value.

However, parsing the DN of the defaultNamingContext might be easier.

Joe K.
Post by Richard Mueller [MVP]
Hi,
Use the "DefaultNamingContext" property of the RootDSE object.
MyCompany.MyDomain.com
DC=MyCompany,DC=MyDomain,DC=com
dnsHostName returns a name similar to the first example above,
DefaultNamingContext returns a name similar to the second.
The environment variable and ADSystemInfo return the DNS domain name similar
to the first example. If you use NameTranslate to convert the NetBIOS domain
name to the DNS domain name, it looks like the second example.
--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--
Post by Jurgen Postelmans
Hi,
dnsHostName returns the full name of the server(like
servername.domain.com).
Post by Jurgen Postelmans
What I'm looking for is domain.com.
I'm unsure whether I can just extract the domain name from the
dnsHostName?
Post by Jurgen Postelmans
Is the servername always before the first dot? Isn't there a property in
AD
Post by Jurgen Postelmans
that gives me immediatly the qualified domain name?
Post by Joe Kaplan (MVP - ADSI)
DirectoryEntry de;
string dnsHostName;
using (de)
{
de = new DirectoryEntry("RootDSE");
dnsHostName = (string) de.Properties["dnsHostName"].Value;
}
Joe K.
Post by Jurgen Postelmans
Richard,
I plan to do this from C# code. But any example will do as I do not
have
Post by Jurgen Postelmans
Post by Joe Kaplan (MVP - ADSI)
Post by Jurgen Postelmans
much experience with ADSI programming...
in
Post by Jurgen Postelmans
Post by Joe Kaplan (MVP - ADSI)
Post by Jurgen Postelmans
Post by Richard Mueller [MVP]
Post by Jurgen
Is there any way that from a Windows XP client that is part of the
domain you can findout the fully qualified Active Directory name like
test.com?
Hi,
1. The environment variable USERDNSDOMAIN.
2. The DomainDNSName property of the ADSystemInfo object.
3. The DefaultNamingContext property of the RootDSE object.
4. You can retrieve the NetBIOS name of the domain (in various ways)
and
Post by Jurgen Postelmans
Post by Joe Kaplan (MVP - ADSI)
Post by Jurgen Postelmans
Post by Richard Mueller [MVP]
use
the NameTranslate object to convert to the DNS domain name.
How you do this depends on what language/platform you are using.
Reply
if
you want VBScript examples.
--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--
Marc Scheuner [MVP ADSI]
2004-11-23 09:13:29 UTC
Permalink
Post by Jurgen Postelmans
dnsHostName returns the full name of the server(like servername.domain.com).
What I'm looking for is domain.com.
I'm unsure whether I can just extract the domain name from the dnsHostName?
Is the servername always before the first dot? Isn't there a property in AD
that gives me immediatly the qualified domain name?
Yes, you can easily get that info from the IADsADSystemInfo interface.
C# sample follows - you need to have a reference to the COM "Active DS
Type Library" and a "using ActiveDs" statement in your C# file for
this to work:

// get a IADsADSystemInfo object and show it
IADsADSystemInfo oSysInfo = new ADSystemInfoClass();
Console.WriteLine(oSysInfo.DomainDNSName);

oSysInfo will contain a number of other interesting fields, too.

HTH
Marc

________________________________________________________________
Marc Scheuner ** mscheuner -at- mvps.org ** http://adsi.mvps.org
Microsoft MVP for Directory Services Programming
http://www.dirteam.com/blogs/mscheuner/default.aspx
Come see http://groups.yahoo.com/group/ADSIANDDirectoryServices/

Continue reading on narkive:
Loading...