Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Function GetUserGroups(ByVal strUserName As String, ByVal strAdminUserId As String, ByVal strAdminPwd As String, ByVal strDomain As String) As String
Try
Dim deentry As DirectoryEntry = New DirectoryEntry("LDAP://" & Trim(strdomain), Trim(strAdminUserId), Trim(strAdminPwd))
Dim dsSearcher As DirectorySearcher = New DirectorySearcher(deentry)
dsSearcher.Filter = ("(sAMAccountName=" & strUserName & ")")
Dim srresult As SearchResult = dsSearcher.FindOne
Dim userpath AS string = trim(srresult.path)
à..More code coming hereà.
Catch ex As Exception
Dim debug As String = ex.Message
GetUserGroups= debug
End Try
æConnect to the object
Dim mySearchRoot As DirectoryEntry = New DirectoryEntry (userpath,strAdminUserId,strAdminPwd)
Dim myDirectorySearcher As New DirectorySearcher(mySearchRoot)
æGet only the result for the property ômemberofö
myDirectorySearcher.PropertiesToLoad.Add("memberof")
æIf you remove the above line then the program will iterate through all the properties.
Dim mySearchResult As SearchResult = myDirectorySearcher.FindOne()
æMaking sure we have results
If Not (mySearchResult Is Nothing) Then
Dim strGrpList As String = ""
Dim myCollection As Object
For Each myCollection In mySearchResult.Properties("memberof")
æRemoving extra LDAP path information from the collection
æ You may want to modify it as per your requirements
strGrpList = strGrpList & Replace(Left(myCollection, InStr(myCollection, ",OU", CompareMethod.Text)), "CN=", "")
Next myCollection
GetUserGroups = tabl
Else
GetUserGroups = "Path Not Found or Object not found"
End if