'(Declarations) ' Available Objects: ' BaseObjectEngine - PCS Base Object Engine ' LookupObjectEngine - PCS Lookup Table Engine ' WorkflowData - PCS Workflow Data Engine ' MetaObjectEngine - PCS Def Object Engine ' DB - PCS Database Engine ' DataItem - PCS Workflow DataItem ' ScriptInfoObject - PCS Workflow Script Parameter Collection ' 'End of (Declarations) Dim oRootDSE Dim strNamingContext Dim strConfigContext Dim strRootContext Dim oContainer Dim Domain Dim oPartitions Dim lCount Dim strCanonical Dim strDNSName Const ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP = 4 Const ADS_GROUP_TYPE_GLOBAL_GROUP = 2 Const ADS_GROUP_TYPE_LOCAL_GROUP = 4 Const ADS_GROUP_TYPE_SECURITY_ENABLED = -2147483648# Const ADS_GROUP_TYPE_UNIVERSAL_GROUP = 8 Public Function WorkflowScript() '============================================================== ' On Error Resume Next is the only form of error handling in ' VBScript. If an error is raised out of a script while it ' is running, it may cause the workflow system to slow. ' Therefore, please use On Error Resume Next in conjunction ' with the Err Object to handle any errors ' that may occur. '============================================================== On Error Resume Next 'Active Directory Scripting requires that the logged in user have 'permissions to perform the actions listed in these functions. If 'not logged in with such a user, these functions will not work. Set oRootDSE = GetObject("LDAP://RootDSE") strNamingContext = oRootDSE.Get("defaultNamingContext") strConfigContext = oRootDSE.Get("configurationNamingContext") ' -- Get current Domain name -- Set Domain = GetObject("LDAP://" + strNamingContext) strDomainName = oDomain.Get("name") '-Get the DNS name of the domain- Domain.GetInfoEx Array("canonicalName"), 0 strCanonical = Domain.Get("canonicalName") strDNSName = Left(strCanonical, Len(strCanonical) - 1) 'clip off "/" '=============================================== ' The following values are valid return codes '----------------------------------------------- ' 0 = Success - (Default) ' -1 = Failure - Mark task as failed ' -2 = Failure - Mark task as failed and Raise WithException Flag ' -3 = Failure - Mark task as failed and Rollback workflow '=============================================== WorkflowScript = 0 '(Default) Success End Function Public Function CreateUser(ByVal UserName, ByVal Password) Dim usr Set usr = ouIS1.Create("user", "CN=" & UserName) usr.Put "samAccountName", UserName usr.Put "userPrincipalName", UserName & "@" & strDNSName usr.Put "userAccountControl", "0020" usr.SetInfo usr.SetPassword Password End Function Public Function CreateGroup(ByVal strPath, ByVal strGroupName, ByVal strSamAcctName, ByVal strGroupType, ByVal bSecurity) ' ========================================================= 'CreateGroup(strPath As String, strGroupName As String, strSamAcctName As String, strGroupType As String, bSecurity As Boolean) ' strPath = ADsPath of the Container under which the group will be created ' strGroupName = Name of the Group to be Created ' strSamAcctName = Group name as it will appear to pre-Windows2000 machines ' strGroupType = Type of group to be created(Local,Domain Local, Global, or Universal) ' bSecurity = Is this a security group? ' ========================================================= Dim lGroupType Dim oContainer Dim oGroup ' --- Set the type of Group ------ lGroupType = 0 Select Case UCase(strGroupType) Case "LOCAL" lGroupType = ADS_GROUP_TYPE_LOCAL_GROUP Case "DOMAIN LOCAL" lGroupType = ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP Case "GLOBAL" lGroupType = ADS_GROUP_TYPE_GLOBAL_GROUP Case "UNIVERSAL" lGroupType = ADS_GROUP_TYPE_UNIVERSAL_GROUP Case Else MsgBox "This is not a proper group type" Exit Function End Select ' ---- Check to see if it is a Security Group ---- If bSecurity Then lGroupType = lGroupType Or ADS_GROUP_TYPE_SECURITY_ENABLED End If ' ---- Create the Group ---- Set oContainer = GetObject(strPath) Set oGroup = oContainer.Create("group", "cn=" + strGroupName) oGroup.Put "SAMAccountName", strSamAcctName oGroup.Put "groupType", lGroupType oGroup.SetInfo Set oGroup = Nothing Set oContainer = Nothing End Function Public Function CreateOU(ByVal OUName, ByVal OUDesc) Dim ouTest Set ouTest = Domain.Create("organizationalUnit", "OU=" & OUName) ouTest.Put "Description", OUDesc ouTest.SetInfo End Function