ActiveDirectoryInterfaces Split Distinguished Name
This commit is contained in:
parent
766737b4b5
commit
f7f4b05df5
@ -220,12 +220,22 @@ Public Class ActiveDirectoryInterface
|
|||||||
Return oUsers
|
Return oUsers
|
||||||
End Try
|
End Try
|
||||||
End Function
|
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
|
Public Function FindUserWithFilter(pUser As UserPrincipalEx, pFilter As String) As Boolean
|
||||||
Try
|
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: 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 oPlaceholder = "@SAMACCOUNTNAME"
|
||||||
Dim oProtocol = "LDAP://"
|
Dim oProtocol = "LDAP://"
|
||||||
@ -250,8 +260,9 @@ Public Class ActiveDirectoryInterface
|
|||||||
Dim oSearcher As New DirectorySearcher(oEntry, pFilter)
|
Dim oSearcher As New DirectorySearcher(oEntry, pFilter)
|
||||||
_logger.Debug("FindUserWithFilter: oSearcher created! Now executing DirectoryServices.SearchResult with .FindOne ...")
|
_logger.Debug("FindUserWithFilter: oSearcher created! Now executing DirectoryServices.SearchResult with .FindOne ...")
|
||||||
Dim oResult As SearchResult = oSearcher.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
|
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
|
Return True
|
||||||
Else
|
Else
|
||||||
Return False
|
Return False
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user