pixabay_vb

Benutzerdefinierte Exception (VB.NET)

Imports System.Runtime.Serialization <Serializable> Public Class ActiveDirectoryManagerException Inherits Exception Public Sub New() End Sub Public Sub New(ByVal message As String) End Sub Public Sub New(ByVal message As String, ByVal inner As Exception) End Sub Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext) End Sub End Class

pixabay_vb

Simple UnitTest (VB.NET)

Imports System.Text Imports GRI.ActiveDirectoryManagement Imports GRI.ActiveDirectoryManagement.Contracts Imports Microsoft.VisualStudio.TestTools.UnitTesting <TestClass()> Public Class ActiveDirectoryManagementTest Private ReadOnly _activeDirectoryManager As IActiveDirectoryManager = New ActiveDirectoryManager Private Const Domain As String = „DomainName“ <TestMethod()> <Owner(„OwnerName“)> Public Sub TestSidCorrect() Dim users = _activeDirectoryManager.GetAllUsersAsSidWithSamAccountName(Domain) Dim actual = users.ContainsValue(„firstname.lastname“) AndAlso users.ContainsKey(„S-1-5-21-49350932-217275072-1489575960-4818“) Const expected = True Assert.AreEqual(expected, actual) End Sub End Class

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 […]

pixabay_vb

DependencyInjection – WindowsForms (VB.NET)

Imports GRI.ActiveDirectoryManagement.Contracts Imports GRI.ActiveDirectoryMonitor.DependencyInjection Imports Ninject   Public Class FormDefault Private Shared ReadOnly Kernel As IKernel = New StandardKernel() Private _activeDirectoryManager As IActiveDirectoryManager Private Sub FormDefault_Load(sender As Object, e As EventArgs) Handles MyBase.Load Kernel.Load(New ActiveDirectoryManagementModule()) _activeDirectoryManager = Kernel.[Get](Of IActiveDirectoryManager)() End Sub Private Sub ButtonAdUserGet_Click(sender As Object, e As EventArgs) Handles ButtonAdUserGet.Click ‚Input validieren Dim users […]

pixabay_vb

DataBaseManagementMssql (VB.NET)

Imports System Imports System.Collections.Generic Imports System.Data Imports System.Data.SqlClient Imports System.Drawing Imports System.IO Imports GRI.CryptManagement.Contracts Imports GRI.DataBaseManagementMssql2008.Contracts Imports Ninject Namespace GRI.DataBaseManagementMssql2008 Public Class DataBaseManagerMssql2008 Inherits IDataBaseManagerMssql2008 Private ReadOnly _cryptManager As ICryptManager <Inject> Public Sub New(ByVal cryptManager As ICryptManager) _cryptManager = cryptManager End Sub Public Function GetDataTable(ByVal connectionString As String, ByVal queryString As String, ByVal Optional parameterList […]