update active directory interface to sync to mssql and to sync custom attributes

This commit is contained in:
Jonathan Jenne
2019-04-17 16:29:44 +02:00
parent 32b000c947
commit 0374016cde
10 changed files with 437 additions and 133 deletions

View File

@@ -0,0 +1,36 @@
Imports System.DirectoryServices.AccountManagement
<DirectoryRdnPrefix("CN")>
<DirectoryObjectClass("Person")>
Public Class UserPrincipalEx
Inherits UserPrincipal
Public Sub New(Context As PrincipalContext)
MyBase.New(Context)
End Sub
Public Sub New(Context As PrincipalContext, samAccountName As String, Password As String, Enabled As Boolean)
MyBase.New(Context, samAccountName, Password, Enabled)
End Sub
Public Overloads Shared Function FindByIdentity(ByVal Context As PrincipalContext, ByVal IdentityValue As String) As UserPrincipalEx
Return CType(FindByIdentityWithType(Context, GetType(UserPrincipalEx), IdentityValue), UserPrincipalEx)
End Function
Public Overloads Shared Function FindByIdentity(ByVal Context As PrincipalContext, ByVal IdentityType As IdentityType, ByVal IdentityValue As String) As UserPrincipalEx
Return CType(FindByIdentityWithType(Context, GetType(UserPrincipalEx), IdentityType, IdentityValue), UserPrincipalEx)
End Function
Public Function GetAttributeValue(AttributeName As String) As String
Return TryGetAttribute(AttributeName)
End Function
Private Function TryGetAttribute(AttributeName As String) As String
Dim oAttribute = ExtensionGet(AttributeName)
If oAttribute.Length <> 1 Then
Return String.Empty
End If
Return CStr(oAttribute(0))
End Function
End Class