pixabay_vb

Implementation eines Contracts / Interface (VB.NET)

Imports System.DirectoryServices.AccountManagement

Imports GRI.ActiveDirectoryManagement.Contracts

Public Class ActiveDirectoryManager

Implements IActiveDirectoryManager

Public Function GetAllUsersAsSidWithSamAccountName(domain As String) As Dictionary(Of String, String) Implements IActiveDirectoryManager.GetAllUsersAsSidWithSamAccountName

Try

Dim activeDirectory As New PrincipalContext(ContextType.Domain, domain)

Dim userPrincipal As New UserPrincipal(activeDirectory)

Dim userPrincipals As New PrincipalSearcher(userPrincipal)

Return userPrincipals.FindAll().Cast(Of UserPrincipal)().Where(Function(result) result IsNot Nothing AndAlso result.Sid IsNot Nothing AndAlso result.SamAccountName IsNot Nothing).ToDictionary(Function(result) result.Sid.ToString(), Function(result) result.SamAccountName)

Catch ex As Exception

Throw New ActiveDirectoryManagerException(„“, ex)

End Try

End Function

Public Function GetGroupMembership(userName As String) As IEnumerable(Of String) Implements IActiveDirectoryManager.GetGroupMembership

Throw New NotImplementedException

End Function

End Class

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

*