I am trying to create a security group in AD, the code below will create the group at the top OU level which is the domain, but I need the code to go 2 Ous deeper. We have an Ou called departments under the domain OU, and then under departments we have the actual departments like HR for example
Any help would be appreciated
Thanks
Option Explicit
Dim objContainer, objGroup,strGroupDescr
Dim ou
Dim cn
ou = InputBox ("Enter Domain")
cn = InputBox ("Enter Security Group")
strGroupDescr = ou & ":"& cn & ":" &"group"
ou=UCase (ou)
cn=UCase (cn)
strGroupDescr=UCase (strGroupDescr)
Const ADS_GROUP_TYPE_GLOBAL_GROUP = &H2
Const ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP = &H4
Const ADS_GROUP_TYPE_LOCAL_GROUP = &H4
Const ADS_GROUP_TYPE_UNIVERSAL_GROUP = &H8
Const ADS_GROUP_TYPE_SECURITY_ENABLED = &H80000000
Set objContainer = GetObject("LDAP://OU=" & ou & ",DC=TEST,DC=lan")
Set objGroup = objContainer.Create("group", "CN=" & cn)
Call objGroup.Put("sAMAccountName", cn)
Call objGroup.Put("groupType", ADS_GROUP_TYPE_GLOBAL_GROUP + _
ADS_GROUP_TYPE_SECURITY_ENABLED)
call objGroup.Put ("description", strGroupDescr)
objGroup.SetInfo
Any help would be appreciated
Thanks
Option Explicit
Dim objContainer, objGroup,strGroupDescr
Dim ou
Dim cn
ou = InputBox ("Enter Domain")
cn = InputBox ("Enter Security Group")
strGroupDescr = ou & ":"& cn & ":" &"group"
ou=UCase (ou)
cn=UCase (cn)
strGroupDescr=UCase (strGroupDescr)
Const ADS_GROUP_TYPE_GLOBAL_GROUP = &H2
Const ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP = &H4
Const ADS_GROUP_TYPE_LOCAL_GROUP = &H4
Const ADS_GROUP_TYPE_UNIVERSAL_GROUP = &H8
Const ADS_GROUP_TYPE_SECURITY_ENABLED = &H80000000
Set objContainer = GetObject("LDAP://OU=" & ou & ",DC=TEST,DC=lan")
Set objGroup = objContainer.Create("group", "CN=" & cn)
Call objGroup.Put("sAMAccountName", cn)
Call objGroup.Put("groupType", ADS_GROUP_TYPE_GLOBAL_GROUP + _
ADS_GROUP_TYPE_SECURITY_ENABLED)
call objGroup.Put ("description", strGroupDescr)
objGroup.SetInfo