Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27248

how to get a list of computer's group membership

$
0
0
'--------------------------------------------------------------------------------------------------------------------------
' - Start - User's PC Group Membership
'--------------------------------------------------------------------------------------------------------------------------
Try
Dim strADsPath As String = "", oCont

'/Find the Global Catalog server
oCont = GetObject("GC:")
For Each oGC In oCont
strADsPath = oGC.ADsPath
Exit For
Next

Dim MaxDe1 As New DirectoryEntry(strADsPath, GblAdminID, GblAdminPass)
MaxDe1.AuthenticationType = AuthenticationTypes.Secure
Dim maxDs1 As New System.DirectoryServices.DirectorySearcher(MaxDe1)

maxDs1.Filter = ("(&(objectCategory=computer)(cn=" & GblStrComputer & "))")
maxDs1.PageSize = 5
maxDs1.ServerTimeLimit = New TimeSpan(0, 0, 30)
maxDs1.ClientTimeout = New TimeSpan(0, 10, 0)
maxDs1.PropertiesToLoad.Add("MemberOf")
maxDs1.PropertiesToLoad.Add("description")
maxDs1.PropertiesToLoad.Add("cn")
Dim objResult1 As SearchResult = maxDs1.FindOne()


NumberOfGroups = objResult1.Properties("memberOf").Count() - 1

''''''- This returns -1 .i.e. 0 result

While (NumberOfGroups >= 0)
tempString = objResult1.Properties("MemberOf").Item(NumberOfGroups)
End While

how do i get computer's group membership , the same code works for user's group membership , but with ldap


Dim MaxDe As New DirectoryEntry("LDAP://" & userDomain, GblAdminID, GblAdminPass)
Dim maxDs As New DirectorySearcher(MaxDe)
maxDs .Filter = "(SAMAccountName=" & UserId & ")"
maxDs .PropertiesToLoad.Add("MemberOf")

any idea ?

Viewing all articles
Browse latest Browse all 27248

Trending Articles