To add a member to the group you can use pre-existing UDFs. Try looking up "GroupAdd"

Here is a function to create an AD group in a specified container. I will be formalizing this and posting it to the UDF Library later today or tomorrow.


Function CreateADGroup ($Container, $GrpName, $GrpType, $SecurityEnabled, optional $Description, optional $sSAMAcctName)

;ADS_GROUP_TYPE_GLOBAL_GROUP = 0x00000002,
;ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP = 0x00000004,
;ADS_GROUP_TYPE_LOCAL_GROUP = 0x00000004,
;ADS_GROUP_TYPE_UNIVERSAL_GROUP = 0x00000008,
;ADS_GROUP_TYPE_SECURITY_ENABLED = 0x80000000

Dim $oOU, $oNewGrp

Select
Case $GrpType = "local" $GrpType = &00000004
Case $GrpType = "global" $GrpType = &00000002
Case $GrpType = "universal" $GrpType = &00000008
Case 1
;WriteLog2($LogFile, "Function: CreateADGroup - Parameter(GrpType) Error: " + @error + " " + @serror
exit 87
EndSelect
If not ($SecurityEnabled = 1 or $SecurityEnabled = 0)
;WriteLog2($LogFile, "Function: CreateADGroup - Parameter(SecurityEnabled) Error: " + @error + " " + @serror
exit 87
EndIf
If $SecurityEnabled
$GrpType = $GrpType | &80000000
EndIF

If VarTypeName($sSAMAcctName) = "Empty"
$sSAMAcctName = $GrpName
EndIf
If Len($sSAMAcctName) > 20 Then
; "SamAccountName CANNOT be bigger than 20 characters"
$sSAMAcctName = left($sSAMAcctName, 20)
EndIf


$oOU = GetObject("LDAP://" + $Container)
If @error = 0
$oNewGrp = $oOU.Create("group", "CN=" + $GrpName)
$oNewGrp.Put("sAMAccountName", $sSAMAcctName)
$oNewGrp.Put("GroupType", $GrpType)
If VarTypeName($Description) <> "Empty"
$oNewGrp.Put("Description", $Description)
Endif
$oNewGrp.SetInfo
If @error <> 0
;WriteLog2($LogFile, "Function: CreateADGroup - SetInfo Error: " + @error + " " + @serror
exit @error
EndIf
Else
;WriteLog2($LogFile, "Function: CreateADGroup - Get OU Error: " + @error + " " + @serror
exit @error
EndIf
$oOU = 0
$oNewGrp = 0
exit 0


[ 23. July 2003, 17:43: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/