Applies To:
GroupID 8 and above - Automate
Business Scenario:
You do not have the Active Directory attributes for Location or Title populated for your users. However, your users are organized in the directory according to their company's location, so you can still make use of your organizational unit structure and create a Dynasty based on that.
Steps:
- In GroupID Management Console, select Automate > right-click All Groups > New > Dynasty.
The New Dynasty wizard opens to the Welcome page. - Go through the pages of the wizard until you reach the Dynasty Template page. Here, select the Custom option button and click Next.
- On the Dynasty Options page, click Add.
- On the GroupBy settings dialog box, select the distinguishedName attribute in the Group items by list and click OK. Then click Next on the Dynasty Options page.
- On the Query Options page, click Modify; the Query Designer dialog box is displayed.
- On the Query Designer, select the scope of the Dynasty by clicking Start In, and then selecting the required OU; a group will be created for each OU under the Start In OU.
- Click OK to close the Query Designer and then click Next on the Query Options page of the wizard.
- On the Update Options page, select the Update Later and then the Choose Later option buttons, and click Next.
- On the Completion page, click Finish and then Close.
- Right-click this newly created Dynasty and select Properties on the shortcut menu.
- On the GroupID tab in group properties, click the Options button.
- On the Dynasty Options dialog box, click on the selected GroupBy attribute and then click Edit Script.
- In the Script Editor, replace everything with the script below:
'Warning: Do not alter method name
Sub SetDynastyOptions(Byval args as DynastyEventArgs)
'Uncomment below lines to customize
args.GroupBy = "distinguishedName"
'args.ChildContainer = "OU=MarsGroups,DC=mars,DC=com"
'args.Separator = ""
args.FilterMethodName = "GroupByFilter"
'args.FilterLDAPSearchFormat = "{0}*"
End SubPublic Function SuperMid(ByVal strMain As String, str1 As String, str2 As String, reverse As Boolean) As String
'DESCRIPTION: Extract the portion of a string between the two substrings defined in str1 and str2.
'HOW TO USE: - Pass the argument your main string and the 2 strings you want to find in the main string.
' - This function will extract the values between the end of your first string and the beginning of your next string.
' - If the optional boolean "reverse" is true, an InStrRev search will occur to find the last instance of the substrings in your main string.
Dim i As Integer, j As Integer, temp As object
On Error GoTo errhandler:
If reverse = True Then
i = InStrRev(strMain, str1)
j = InStrRev(strMain, str2)
If i = j Then 'try to search 2nd half of string for unique match
j = InStrRev(strMain, str2, i - 1)
End If
Else
i = InStr(1, strMain, str1)
j = InStr(1, strMain, str2)
If i = j Then 'try to search 2nd half of string for unique match
j = InStr(i + 1, strMain, str2)
End If
End If
If i = 0 And j = 0 Then GoTo errhandler:
If j = 0 Then j = Len(strMain) + Len(str2) 'just to make it arbitrarily large
If i = 0 Then i = Len(strMain) + Len(str1) 'just to make it arbitrarily large
If i > j And j <> 0 Then 'swap order
temp = j
j = i
i = temp
temp = str2
str2 = str1
str1 = temp
End If
i = i + Len(str1)
SuperMid = Mid(strMain, i, j - i)
Exit Function
errhandler:
MsgBox ("Error extracting strings. Check your input" & vbNewLine & vbNewLine & "Aborting", , "Strings not found")
End Function
'Warning: Do not alter method name
Function GroupByFilter(Byval value as string) As string
dim str1, str2, str3 as string
str1 = "OU="
str2 = "OU"
str3 = SuperMid(value, str1, str2, FALSE)
str1 = replace(str3, ",")
Return str1
End Function -
Click Compile Script and then click OK to close the Script Editor after success.
-
On the Dynasty Options dialog box, click Apply and then OK.
-
On the GroupID tab, click Update to update the Dynasty.
Expectedly, a group for each organizational unit will be created.
The script is attached to avoid copy and paste issues.
Reference:
GroupID Online Help topic: Create a Dynasty