ActiveDirectoryInterfaces Split Distinguished Name
This commit is contained in:
parent
766737b4b5
commit
f7f4b05df5
@ -220,12 +220,22 @@ Public Class ActiveDirectoryInterface
|
||||
Return oUsers
|
||||
End Try
|
||||
End Function
|
||||
Private Function GetPartFromFirstOU(dnString As String) As String
|
||||
Dim keyword As String = "OU="
|
||||
Dim index As Integer = dnString.IndexOf(keyword)
|
||||
|
||||
If index <> -1 Then
|
||||
Return dnString.Substring(index)
|
||||
Else
|
||||
Return "No_Result_from_GetPartFromFirstOU"
|
||||
End If
|
||||
End Function
|
||||
Public Function FindUserWithFilter(pUser As UserPrincipalEx, pFilter As String) As Boolean
|
||||
Try
|
||||
Dim oRootPath = String.Join(","c, pUser.DistinguishedName.Split(","c).Skip(1))
|
||||
'Dim oRootPath = String.Join(","c, pUser.DistinguishedName.Split(","c).Skip(1))
|
||||
Dim oRootPath = GetPartFromFirstOU(pUser.DistinguishedName)
|
||||
_logger.Debug("FindUserWithFilter: pUser.DistinguishedName: [{0}]", pUser.DistinguishedName)
|
||||
_logger.Debug("FindUserWithFilter: oRootPath from User.DistinguishedName - oRootPath: [{0}]", oRootPath)
|
||||
_logger.Debug("FindUserWithFilter: oRootPath from User.DistinguishedName: [{0}]", oRootPath)
|
||||
|
||||
Dim oPlaceholder = "@SAMACCOUNTNAME"
|
||||
Dim oProtocol = "LDAP://"
|
||||
@ -250,8 +260,9 @@ Public Class ActiveDirectoryInterface
|
||||
Dim oSearcher As New DirectorySearcher(oEntry, pFilter)
|
||||
_logger.Debug("FindUserWithFilter: oSearcher created! Now executing DirectoryServices.SearchResult with .FindOne ...")
|
||||
Dim oResult As SearchResult = oSearcher.FindOne()
|
||||
_logger.Debug("FindUserWithFilter: We have an oResult - oResult.Path: [{0}]", oResult.Path)
|
||||
|
||||
If oResult IsNot Nothing AndAlso oResult.Path.Replace(oProtocol, String.Empty) = pUser.DistinguishedName Then
|
||||
_logger.Debug("FindUserWithFilter: We have an oResult - oResult.Path: [{0}]", oResult.Path)
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user