View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jake Marx[_3_] Jake Marx[_3_] is offline
external usenet poster
 
Posts: 860
Default Active Directory

Hi Ulf,

Ulf Nilsson wrote:
I want to know how many users there are in a specific
group, for example P_Excel, in Active Directory.
Is it posible to exclude all users beginning with "t_"?

Where can I read more about this? Or, I would be thankful
if someone can provide with examples.


If you do a google search on "ADSI" and "group" and "user", you should find
some articles with more information. But here's a subroutine that will do
what you're looking for:

Sub EnumerateGroupInAD()
Dim objAD As Object
Dim objUser As Object
Dim sDomain As String
Dim sGroup As String
Dim nNumUsers As Integer

sDomain = "YourDomain"
sGroup = "P_Excel"

Set objAD = GetObject("WinNT://" & sDomain & _
"/" & sGroup)

For Each objUser In objAD.Members
If Left$(objUser.Name, 2) < "t_" Then
nNumUsers = nNumUsers + 1
Debug.Print objUser.Name
End If
Next objUser

Debug.Print vbLf & CStr(nNumUsers) & _
" total users in group " & sGroup & "."

Set objAD = Nothing
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]