{"id":67333,"date":"2006-05-12T09:38:00","date_gmt":"2006-05-12T09:38:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2006\/05\/12\/how-can-i-convert-a-global-security-group-to-a-universal-security-group\/"},"modified":"2006-05-12T09:38:00","modified_gmt":"2006-05-12T09:38:00","slug":"how-can-i-convert-a-global-security-group-to-a-universal-security-group","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-convert-a-global-security-group-to-a-universal-security-group\/","title":{"rendered":"How Can I Convert a Global Security Group to a Universal Security Group?"},"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 convert a global security group to a universal security group?<BR><BR>&#8212; BB<\/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, BB. We have to tell you the truth, we were pretty excited when we first read your email. Convert a global security group to a universal security group? That sounded like a mad scientist sort of thing, and we had visions of setting up a huge lab with all sorts of cool machines and beakers of chemicals, and then one of us would throw a switch and a great bolt of lighting would surge through the room. Everything would be quiet, and then, through the smoke, we\u2019d see our little security group beginning to twitch. \u201cHeaven help us,\u201d we\u2019d say. \u201cWe\u2019ve created a universal security group!\u201d<\/P>\n<P>Cool, huh? In fact, we had already written the screenplay and signed a contract for a series of action figures before we found out that we didn\u2019t actually need a mad scientist\u2019s laboratory to convert a global group to a universal group. Instead, all we needed was this:<\/P><PRE class=\"codeSample\">Const ADS_GROUP_TYPE_UNIVERSAL_GROUP = &amp;H8\nConst ADS_GROUP_TYPE_SECURITY_ENABLED = &amp;H80000000<\/p>\n<p>Set objGroup = GetObject _\n    (&#8220;LDAP:\/\/cn=Managers,ou=Finance,dc=fabrikam,dc=com&#8221;) <\/p>\n<p>objGroup.Put &#8220;groupType&#8221;, ADS_GROUP_TYPE_UNIVERSAL_GROUP OR ADS_GROUP_TYPE_SECURITY_ENABLED\nobjGroup.SetInfo\n<\/PRE>\n<P>Hey, if you think you\u2019re disappointed imagine how <I>we<\/I> feel. As it turns out, though, each Active Directory group has a property named <B>groupType<\/B> that, well, determines the group type. GroupType is a bitmask attribute that can be made up of as many as two different values. Value 1 determines whether the group is a security group or a distribution group. (What\u2019s the difference? Security groups can be given access to resources; distribution groups can\u2019t.) Value 2, meanwhile, determines the type of security group or the type of distribution group. Either security groups or distribution groups can be one of the following:<\/P>\n<TABLE border=\"0\" cellSpacing=\"0\" cellPadding=\"0\">\n<TBODY>\n<TR>\n<TD class=\"listBullet\" vAlign=\"top\">\u2022<\/TD>\n<TD class=\"listItem\">\n<P><B>Global groups<\/B>, in which all the users must come from the same domain.<\/P><\/TD><\/TR>\n<TR>\n<TD class=\"listBullet\" vAlign=\"top\">\u2022<\/TD>\n<TD class=\"listItem\">\n<P><B>Domain local groups<\/B>, in which members can be drawn from any domain in the forest, but permissions can only be granted to the local domain (that is, the domain where the group account resides).<\/P><\/TD><\/TR>\n<TR>\n<TD class=\"listBullet\" vAlign=\"top\">\u2022<\/TD>\n<TD class=\"listItem\">\n<P><B>Universal groups<\/B>, in which members can be drawn from any domain in the forest and be granted permissions anywhere in the forest.<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<P>Fascinating, isn\u2019t it?<\/P>\n<P>By the way, that\u2019s a good question: how <I>can<\/I> a single attribute consist of more than one value? That\u2019s bitmask attributes for you. We won\u2019t discuss bitmasks in any detail today; if you\u2019d like a more thorough discussion, check out this Scripting Guys <A href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkId=24419\" target=\"_blank\"><B>webcast<\/B><\/A>. For now, think of the groupType attribute as being like a series of switches. Suppose the switch for security group is on, the switch for global group is on, and all the other switches are off? In that case, we\u2019d have a global security group. That implies that we can convert a group to a universal security group simply by ensuring that only the security group and the universal group switches are on. And that\u2019s exactly what our script does. <\/P>\n<TABLE id=\"E5D\" 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>. This is probably a good time to point out that Active Directory imposes a few limitations when it comes to converting from one group to another. For example, you can\u2019t convert a global group to a domain local group; Active Directory won\u2019t allow that. Likewise, you can only convert groups if your domain is in native mode. Groups in a mixed-mode domain can\u2019t be converted. Check the <A href=\"http:\/\/null\/technet\/prodtechnol\/windows2000serv\/technologies\/activedirectory\/maintain\/adusers.mspx\" target=\"_blank\"><B>Active Directory documentation<\/B><\/A> for more information.<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>These \u201cswitches\u201d are actually a series of constants and their corresponding values. In fact, they\u2019re actually <I>this<\/I> series of constants and their corresponding values:<\/P>\n<TABLE id=\"EUE\" class=\"dataTable\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\"><B>Group Type<\/B><\/P><\/TD>\n<TD>\n<P class=\"lastInCell\"><B>Constant<\/B><\/P><\/TD>\n<TD>\n<P class=\"lastInCell\"><B>Value<\/B><\/P><\/TD><\/TR>\n<TR class=\"evenRecord\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\">Global group<\/P><\/TD>\n<TD>\n<P class=\"lastInCell\">ADS_GROUP_TYPE_GLOBAL_GROUP<\/P><\/TD>\n<TD>\n<P class=\"lastInCell\">&amp;H2<\/P><\/TD><\/TR>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\">Domain local group<\/P><\/TD>\n<TD>\n<P class=\"lastInCell\">ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP<\/P><\/TD>\n<TD>\n<P class=\"lastInCell\">&amp;H4<\/P><\/TD><\/TR>\n<TR class=\"evenRecord\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\">Universal group<\/P><\/TD>\n<TD>\n<P class=\"lastInCell\">ADS_GROUP_TYPE_UNIVERSAL_GROUP<\/P><\/TD>\n<TD>\n<P class=\"lastInCell\">&amp;H8<\/P><\/TD><\/TR>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\">Security group<\/P><\/TD>\n<TD>\n<P class=\"lastInCell\">ADS_GROUP_TYPE_SECURITY_ENABLED<\/P><\/TD>\n<TD>\n<P class=\"lastInCell\">&amp;H80000000<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>To explain how you can set these switches, let\u2019s go back to our script. We start out by defining a pair of constants: ADS_GROUP_TYPE_UNIVERSAL_GROUP and ADS_GROUP_TYPE_SECURITY_ENABLED. Why these two constants? That\u2019s easy: we want to create a universal security group, which means we need to flip the switches for universal group and for security group. If we wanted to create a universal <I>distribution<\/I> group then we\u2019d only need to flip one switch and define one constant: ADS_GROUP_TYPE_UNIVERSAL_GROUP. (Because, of course, the security group switch needs to be <I>off<\/I> in order for us to have a distribution group.)<\/P>\n<P>After binding to the group account in Active Directory (for this sample script that\u2019s the Managers group in the Finance OU) we encounter this line of code:<\/P><PRE class=\"codeSample\">objGroup.Put &#8220;groupType&#8221;, ADS_GROUP_TYPE_UNIVERSAL_GROUP OR ADS_GROUP_TYPE_SECURITY_ENABLED\n<\/PRE>\n<P>This is where we set the value of the groupType attribute. To do that, we pass our two constants as parameters, joining the two with the OR operator. Don\u2019t worry too much about OR; in this case we can read it as though it was the word <I>and<\/I>: \u201cSet the group type to a universal group <I>and<\/I> a security group.\u201d If we wanted to convert the group to a global security group we would simply need to define the constant ADS_GROUP_TYPE_GLOBAL_GROUP and then use <I>this<\/I> code:<\/P><PRE class=\"codeSample\">objGroup.Put &#8220;groupType&#8221;, ADS_GROUP_TYPE_GLOBAL_GROUP OR ADS_GROUP_TYPE_SECURITY_ENABLED\n<\/PRE>\n<P>Only the switch values we pass to groupType will be flipped on; any other switches will be turned off. And, yes, if you pass a nonsensical request &#8211; for example, passing all the possible constants &#8211; the script will simply fail. Active Directory won\u2019t allow you to create, say a domain local universal security distribution group. <\/P>\n<P>And for good reason.<\/P>\n<P>Make sense? To make it a universal <I>distribution<\/I> group we\u2019d pass just one parameter, ADS_GROUP_TYPE_UNIVERSAL_GROUP:<\/P><PRE class=\"codeSample\">objGroup.Put &#8220;groupType&#8221;, ADS_GROUP_TYPE_UNIVERSAL_GROUP\n<\/PRE>\n<P>Again, that\u2019s because we don\u2019t enable the security group switch (ADS_GROUP_TYPE_SECURITY_ENABLED) for distribution groups.<\/P>\n<P>At any rate, after setting the groupType all we have to do is call the <B>SetInfo<\/B> method and the group will change from a global security group to a universal security group, just like that.<\/P>\n<P>And, no, sorry: the change is made without any bolts of lightning, bursting beakers of chemicals, or other special effects. Hmmm, maybe that\u2019s why they turned down our proposal to use a scripting theme for the latest <I>Mission:Impossible<\/I> movie. <\/P>\n<P>Oh, well. Wonder if we\u2019re too late to propose a plot for <I>X-Men 3<\/I> \u2026.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! How can I convert a global security group to a universal security group?&#8212; BB Hey, BB. We have to tell you the truth, we were pretty excited when we first read your email. Convert a global security group to a universal security group? That sounded like a mad scientist sort of thing, [&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,44,3,5],"class_list":["post-67333","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-active-directory","tag-groups","tag-scripting-guy","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! How can I convert a global security group to a universal security group?&#8212; BB Hey, BB. We have to tell you the truth, we were pretty excited when we first read your email. Convert a global security group to a universal security group? That sounded like a mad scientist sort of thing, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/67333","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=67333"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/67333\/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=67333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=67333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=67333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}