{"id":66753,"date":"2006-08-04T16:12:00","date_gmt":"2006-08-04T16:12:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2006\/08\/04\/how-can-i-determine-whether-a-domain-is-in-mixed-mode-or-native-mode\/"},"modified":"2006-08-04T16:12:00","modified_gmt":"2006-08-04T16:12:00","slug":"how-can-i-determine-whether-a-domain-is-in-mixed-mode-or-native-mode","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-determine-whether-a-domain-is-in-mixed-mode-or-native-mode\/","title":{"rendered":"How Can I Determine Whether a Domain is in Mixed Mode or Native Mode?"},"content":{"rendered":"<p><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\"> \n<P>Hey, Scripting Guy! How can I determine whether a domain is in mixed mode or native mode?<BR><BR>&#8212; WW<\/P><IMG border=\"0\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" height=\"5\"><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\"><A href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><IMG class=\"farGraphic\" title=\"Script Center\" border=\"0\" alt=\"Script Center\" align=\"right\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" height=\"288\"><\/A> \n<P>Hey, WW. When you listen to a <A href=\"http:\/\/www.seattlemariners.com\/\" target=\"_blank\"><B>Seattle Mariners<\/B><\/A> game on the radio one of the regular features is \u201cStump the Broadcasters.\u201d The premise to Stump the Broadcasters is that listeners send in a baseball question to be asked of the Mariners broadcasters. If you can \u201cstump the broadcasters\u201d (that is, if you ask a question that the broadcasters can\u2019t answer) then you win a fabulous prize. Pretty simple, huh?<\/P>\n<P>The only problem with Stump the Broadcasters is that people send in such silly questions: \u201cWho holds the major league record for most career home runs?\u201d To be honest, you just want to grab these people, shake them, and say, \u201cWhat\u2019s wrong with you? Don\u2019t you <I>want<\/I> to win the fabulous prize? Even people who don\u2019t know anything about baseball know that Hank Aaron holds the record for most career home runs. Holy smokes!\u201d<\/P>\n<TABLE id=\"EHD\" class=\"dataTable\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\"><B>Note<\/B>. Here\u2019s a better question: \u201cWho holds the record for the fewest pitches thrown in a complete game?\u201d The answer: the Boston Braves\u2019 Red Barrett, who needed just 58 pitches (and only one hour and 15 minutes) to defeat the Cincinnati Reds 2-0 back in 1944. But you probably shouldn\u2019t try this question, either. After all, if the Mariners broadcasters read this column every day (as they almost surely do), well, now they know the answer, too.<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>If you want to stump the Mariners broadcasters you need to ask about something no one in their right mind could possibly know, something like \u201cWho holds the record for the fewest pitches thrown in a complete game?\u201d It\u2019s a little different when you try to Stump the Scripting Guys, however. Admittedly, no one in their right mind knows how to use a script to determine whether an Active Directory domain is in mixed mode or native mode. But who said that the Scripting Guys were in their right minds?<\/P><PRE class=\"codeSample\">Set objDomain = GetObject(&#8220;LDAP:\/\/dc=fabrikam,dc=com&#8221;)<\/p>\n<p>If objDomain.nTMixedDomain = 0 Then\n    Wscript.Echo &#8220;Domain is in native mode.&#8221;\nElse\n    Wscript.Echo &#8220;Domain is in mixed mode.&#8221;\nEnd If\n<\/PRE>\n<P>As you can see, it\u2019s actually very easy to determine whether a domain is in native mode or mixed mode. To begin with, you simply connect to the domain itself, something we do with this line of code:<\/P><PRE class=\"codeSample\">Set objDomain = GetObject(&#8220;LDAP:\/\/dc=fabrikam,dc=com&#8221;)\n<\/PRE>\n<P>Why do we connect to the domain? That\u2019s easy: the domain object happens to have an attribute named <B>nTMixedDomain<\/B> that tells us whether the domain is in mixed mode or native mode. If nTMixedDomain is equal to 0 then the domain is in native mode (which basically means that all domain controllers must be running Windows 2000 or Windows Server 2003). If nTMixedDomain is equal to 1 then the domain is in mixed mode, which means that Windows NT 4.0 computers can function as domain controllers. How do we check and report back the value of the nTMixedDomainAttribute? By using this block of code:<\/P><PRE class=\"codeSample\">If objDomain.nTMixedDomain = 0 Then\n    Wscript.Echo &#8220;Domain is in native mode.&#8221;\nElse\n    Wscript.Echo &#8220;Domain is in mixed mode.&#8221;\nEnd If\n<\/PRE>\n<P>Incidentally, the nTMixedDomain attribute is a read-write attribute: if your domain is currently in mixed mode you can use a script to change the value to 0 (and thus put the domain into native mode). Are we going to show you an example of how to do that? No, we\u2019re not. Why? Well, moving from mixed mode to native mode is an irreversible process; because of that we don\u2019t want to give you a script that you might accidentally run, and thus accidentally change the domain mode. But that\u2019s no big deal: now that you know about the nTMixedDomain attribute, and now that you know this attribute is read-write, you should be able to put together a script to move you from mixed mode to native mode without too much trouble.<\/P>\n<P>As long as we\u2019re on the subject, here\u2019s another attribute you might find interesting: <B>msDS-Behavior-Version<\/B>. If you connect to a Windows Server 2003 domain and retrieve the value of this attribute it will tell you the domain functional level (see this <A href=\"http:\/\/support.microsoft.com\/kb\/322692\/\" target=\"_blank\"><B>Knowledge Base article<\/B><\/A> for more details). If you connect to the Partitions container and retrieve the value of this attribute it will tell you the forest level setting (discussed in that same Knowledge Base article). We won\u2019t explain the following code in any detail, but this script does return the forest level setting for a Windows Server 2003 forest:<\/P><PRE class=\"codeSample\">Set objRootDSE = GetObject(&#8220;LDAP:\/\/rootDSE&#8221;)<\/p>\n<p>Set objPartitions = GetObject(&#8220;LDAP:\/\/CN=Partitions,&#8221; &amp; _ \n    objRootDSE.Get(&#8220;configurationNamingContext&#8221;))<\/p>\n<p>If objPartitions.[msDS-Behavior-Version] = 0 Then\n    Wscript.Echo &#8220;This is a mixed-level forest.&#8221;\nElseIf objPartitions.[ msDS-Behavior-Version] = 1 Then\n    Wscript.Echo &#8220;This is a Windows Server 2003 interim-level forest.&#8221;\nElse\n    Wscript.Echo &#8220;This is a Windows Server 2003 forest.&#8221;\nEnd If\n<\/PRE>\n<TABLE id=\"EJE\" class=\"dataTable\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\"><B>Note<\/B>. Why did we put square brackets around the attribute name (<B>[msDS-Behavior-Version]<\/B>)? You obviously haven\u2019t read this <A href=\"http:\/\/null\/technet\/scriptcenter\/resources\/qanda\/jun05\/hey0621.mspx\"><B>previous Hey, Scripting Guy! column<\/B><\/A>, have you?<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>We hope that helps, WW. Now here\u2019s another question for you, and for everyone else out there: From1967 to 1983, Aurelio Rodriguez played third base for several major league baseball teams, most notably the Detroit Tigers. During his tenure there was one thing that made Aurelio Rodriguez absolutely unique among major league ball players. What was that? (Answer below)<\/P>\n<TABLE id=\"E5E\" class=\"dataTable\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P><B>Answer<\/B>. During his time in the big leagues Aurelio Rodriguez was the only major league ball player whose first name contained all five vowels: <B>a-e-i-o-u<\/B>. Raise your hand if you got that one right.<\/P>\n<P>Wait a second: <I>everyone<\/I> got that one right? Hmmm \u2026.<\/P><\/TD><\/TR><\/TBODY><\/TABLE><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! How can I determine whether a domain is in mixed mode or native mode?&#8212; WW Hey, WW. When you listen to a Seattle Mariners game on the radio one of the regular features is \u201cStump the Broadcasters.\u201d The premise to Stump the Broadcasters is that listeners send in a baseball question to [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[7,9,3,4,5],"class_list":["post-66753","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-active-directory","tag-adsi","tag-scripting-guy","tag-scripting-techniques","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! How can I determine whether a domain is in mixed mode or native mode?&#8212; WW Hey, WW. When you listen to a Seattle Mariners game on the radio one of the regular features is \u201cStump the Broadcasters.\u201d The premise to Stump the Broadcasters is that listeners send in a baseball question to [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/66753","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=66753"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/66753\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=66753"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=66753"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=66753"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}