Hi,
I'm VERY new to programming and I've come across an issue that I need assistance on. I have a script that reads an OU in AD and places the group members into an array. I have the list sorted alphabetically. Now I need to have duplicate entries removed from the list. Something like this:
Group Name
A12 Company XYZ Super Users
A12 Company XYZUsers
T04 Client Name Super Users
T04 Client Name Users
etc.
etc.
What I'm trying to do ultimately, is get a list/count of Clients in the array to write to a file. Only 1 of the 2 Clients so the end result is:
A12 Company XYZUsers
T04 Client Name Users
etc.
What can I add to this code? Any help would be GREATLY appreciated!!!
Function Read()
Dim Count
Dim arrNames()
Dim objDuplicate
Dim objGroup, intSize, strUser, StrName, strHolder, objUser, i, j
intSize = 0
Set objGroup = GetObject("LDAP://CN=BLAH,OU=BLADGroups,OU=USERS,OU=BLAH,DC=BLAH,DC=BLAH,DC=COM")
For Each strUser in objGroup.Member
Set objUser = GetObject("LDAP://" & strUser)
ReDim Preserve arrNames(intSize)
arrNames(intSize) = objUser.CN
intSize = intSize + 1
Next
For i = (UBound(arrNames) - 1) to 0 Step -1
For j= 0 to i
If UCase(arrNames(j)) > UCase(arrNames(j+1)) Then
strHolder = arrNames(j+1)
arrNames(j+1) = arrNames(j)
arrNames(j) = strHolder
End If
Next
Next
For Each strName in arrNames
If Mid(strName,4,1) = " " Then
oFile.WriteLine(strName)
LineCount = UBound(arrNames)+ 1
End If
End If
Next
oFile.Close
End Function
I'm VERY new to programming and I've come across an issue that I need assistance on. I have a script that reads an OU in AD and places the group members into an array. I have the list sorted alphabetically. Now I need to have duplicate entries removed from the list. Something like this:
Group Name
A12 Company XYZ Super Users
A12 Company XYZUsers
T04 Client Name Super Users
T04 Client Name Users
etc.
etc.
What I'm trying to do ultimately, is get a list/count of Clients in the array to write to a file. Only 1 of the 2 Clients so the end result is:
A12 Company XYZUsers
T04 Client Name Users
etc.
What can I add to this code? Any help would be GREATLY appreciated!!!
Function Read()
Dim Count
Dim arrNames()
Dim objDuplicate
Dim objGroup, intSize, strUser, StrName, strHolder, objUser, i, j
intSize = 0
Set objGroup = GetObject("LDAP://CN=BLAH,OU=BLADGroups,OU=USERS,OU=BLAH,DC=BLAH,DC=BLAH,DC=COM")
For Each strUser in objGroup.Member
Set objUser = GetObject("LDAP://" & strUser)
ReDim Preserve arrNames(intSize)
arrNames(intSize) = objUser.CN
intSize = intSize + 1
Next
For i = (UBound(arrNames) - 1) to 0 Step -1
For j= 0 to i
If UCase(arrNames(j)) > UCase(arrNames(j+1)) Then
strHolder = arrNames(j+1)
arrNames(j+1) = arrNames(j)
arrNames(j) = strHolder
End If
Next
Next
For Each strName in arrNames
If Mid(strName,4,1) = " " Then
oFile.WriteLine(strName)
LineCount = UBound(arrNames)+ 1
End If
End If
Next
oFile.Close
End Function