This commit is contained in:
PitzM 2025-05-23 12:48:13 +02:00
commit ea7fe74e89
6 changed files with 91 additions and 13 deletions

View File

@ -159,6 +159,13 @@ Public Class MSSQLServer
Return oGDPicture Return oGDPicture
End Using End Using
End Function End Function
Public Function GetDDCatalog() As DataTable
Using oConnection As SqlConnection = GetSQLConnection()
Dim oSQL = Queries.DD_ECM.DD_SELECTS.TBDD_CATALOG
Dim oDT_CATALOG As DataTable = GetDatatable(oSQL)
Return oDT_CATALOG
End Using
End Function
Public Function Get_ConnectionStringforID(pConnectionId As Integer) As String Public Function Get_ConnectionStringforID(pConnectionId As Integer) As String
Dim oConnectionString As String = String.Empty Dim oConnectionString As String = String.Empty

View File

@ -4,6 +4,9 @@
Public Const GdPictureLicense As String = "SELECT COALESCE(MAX(LICENSE),'') FROM TBDD_3RD_PARTY_MODULES WHERE ACTIVE = 1 AND NAME = 'GDPICTURE' AND [VERSION] = '11.2024'" Public Const GdPictureLicense As String = "SELECT COALESCE(MAX(LICENSE),'') FROM TBDD_3RD_PARTY_MODULES WHERE ACTIVE = 1 AND NAME = 'GDPICTURE' AND [VERSION] = '11.2024'"
Public Const GdPictureLicense_REGULAR As String = "SELECT COALESCE(MAX(LICENSE),'') FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE' AND ACTIVE = 1" Public Const GdPictureLicense_REGULAR As String = "SELECT COALESCE(MAX(LICENSE),'') FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE' AND ACTIVE = 1"
End Class End Class
Public Class DD_SELECTS
Public Const TBDD_CATALOG As String = "SELECT * FROM TBDD_CATALOG"
End Class
Public Class Connections Public Class Connections
Public Const AllConnections As String = "SELECT * FROM TBDD_CONNECTION AND AKTIV = 1" Public Const AllConnections As String = "SELECT * FROM TBDD_CONNECTION AND AKTIV = 1"

View File

@ -220,10 +220,23 @@ 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)
Public Function FindUserWithFilter(User As UserPrincipalEx, Filter As String) As Boolean 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 Try
Dim oRootPath = String.Join(","c, User.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: [{0}]", oRootPath)
Dim oPlaceholder = "@SAMACCOUNTNAME" Dim oPlaceholder = "@SAMACCOUNTNAME"
Dim oProtocol = "LDAP://" Dim oProtocol = "LDAP://"
Dim oEntry As New DirectoryEntry(oProtocol & oRootPath) With { Dim oEntry As New DirectoryEntry(oProtocol & oRootPath) With {
@ -231,22 +244,25 @@ Public Class ActiveDirectoryInterface
.Password = Nothing, .Password = Nothing,
.AuthenticationType = AuthenticationTypes.Secure .AuthenticationType = AuthenticationTypes.Secure
} }
_logger.Debug("FindUserWithFilter: got oDirectoryEntry (Path): [{0}]", oProtocol & oRootPath)
If Filter = String.Empty Then If pFilter = String.Empty Then
_logger.Debug("FindUserWithFilter: Filter was empty, returning True for User [{0}]", User.SamAccountName) _logger.Debug("FindUserWithFilter: Filter was empty, returning True for User [{0}]", pUser.SamAccountName)
Return True Return True
End If End If
If Filter.Contains(oPlaceholder) Then If pFilter.Contains(oPlaceholder) Then
Filter = Filter.Replace(oPlaceholder, User.SamAccountName) pFilter = pFilter.Replace(oPlaceholder, pUser.SamAccountName)
_logger.Debug("FindUserWithFilter: Filter.Contains(oPlaceholder) [{0}]", pFilter)
Else Else
_logger.Warn("FindUserWithFilter: Placeholder [{0}] was not found in filter. Results may not be correct.") _logger.Warn("FindUserWithFilter: Placeholder [{0}] was not found in filter. Results may not be correct.")
End If End If
Dim oSearcher As New DirectorySearcher(oEntry, Filter) Dim oSearcher As New DirectorySearcher(oEntry, pFilter)
_logger.Debug("FindUserWithFilter: oSearcher created! Now executing DirectoryServices.SearchResult with .FindOne ...")
Dim oResult As SearchResult = oSearcher.FindOne() Dim oResult As SearchResult = oSearcher.FindOne()
If oResult IsNot Nothing AndAlso oResult.Path.Replace(oProtocol, String.Empty) = User.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

View File

@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("Digital Data")> <Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("Modules.Interfaces")> <Assembly: AssemblyProduct("Modules.Interfaces")>
<Assembly: AssemblyCopyright("Copyright © 2025")> <Assembly: AssemblyCopyright("Copyright © 2025")>
<Assembly: AssemblyTrademark("2.2.9.0")> <Assembly: AssemblyTrademark("")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>
@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("2.2.9.0")> <Assembly: AssemblyVersion("2.3.0.0")>
<Assembly: AssemblyFileVersion("2.2.9.0")> <Assembly: AssemblyFileVersion("2.3.0.0")>

View File

@ -13,6 +13,11 @@ Namespace Modules
Public Const INT_VALUE_DOMAIN = "DOMAIN" Public Const INT_VALUE_DOMAIN = "DOMAIN"
Public Const INT_VALUE_DATE = "DATE" Public Const INT_VALUE_DATE = "DATE"
Public Const INT_VALUE_FILENAME_EXT = "FILENAME_EXT"
Public Const INT_VALUE_FILENAME = "FILENAME_ONLY"
Public Const INT_VALUE_FILE_DATE = "FILE_DATE"
Public Const INT_VALUE_FILEEXT = "FILE_EXT"
Public Const INT_VALUE_DATE_YYYY = "YYYY" Public Const INT_VALUE_DATE_YYYY = "YYYY"
Public Const INT_VALUE_DATE_MM = "MM" Public Const INT_VALUE_DATE_MM = "MM"
Public Const INT_VALUE_DATE_DD = "DD" Public Const INT_VALUE_DATE_DD = "DD"

View File

@ -1,4 +1,5 @@
Imports System.Text.RegularExpressions Imports System.IO
Imports System.Text.RegularExpressions
Imports System.Windows.Forms Imports System.Windows.Forms
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.ZooFlow Imports DigitalData.Modules.ZooFlow
@ -36,6 +37,12 @@ Public Class ClassPatterns
Public Const INT_VALUE_DOMAIN = "DOMAIN" Public Const INT_VALUE_DOMAIN = "DOMAIN"
Public Const INT_VALUE_DATE = "DATE" Public Const INT_VALUE_DATE = "DATE"
Public Const INT_VALUE_FILENAME_EXT = "FILENAME_EXT"
Public Const INT_VALUE_FILENAME = "FILENAME"
Public Const INT_VALUE_FILEEXT = "FILE_EXT"
Public Const INT_VALUE_FILE_DATE = "FILE_DATE"
Public Const CLIPBOARD_VALUE_DE = "@Zwischenablage" Public Const CLIPBOARD_VALUE_DE = "@Zwischenablage"
Public Const CLIPBOARD_VALUE_EN = "@Clipboard" Public Const CLIPBOARD_VALUE_EN = "@Clipboard"
@ -44,6 +51,7 @@ Public Class ClassPatterns
Public Const MAX_TRY_COUNT = 100 Public Const MAX_TRY_COUNT = 100
Public _handled_File As String = Nothing
Public ReadOnly Property PatternRegex As Regex Public ReadOnly Property PatternRegex As Regex
Get Get
@ -132,6 +140,45 @@ Public Class ClassPatterns
oResult = ReplacePattern(oResult, PATTERN_INT, Now.ToShortDateString) oResult = ReplacePattern(oResult, PATTERN_INT, Now.ToShortDateString)
End While End While
While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_FILENAME_EXT)
If Not IsNothing(_handled_File) Then
If File.Exists(_handled_File) Then
Dim oFileName As String = Path.GetFileName(_handled_File)
oResult = ReplacePattern(oResult, PATTERN_INT, oFileName)
End If
End If
End While
While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_FILENAME)
If Not IsNothing(_handled_File) Then
If File.Exists(_handled_File) Then
Dim oFileName As String = Path.GetFileNameWithoutExtension(_handled_File)
oResult = ReplacePattern(oResult, PATTERN_INT, oFileName)
End If
End If
End While
While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_FILEEXT)
If Not IsNothing(_handled_File) Then
If File.Exists(_handled_File) Then
Dim oFileExt As String = Path.GetExtension(_handled_File).Substring(1)
oResult = ReplacePattern(oResult, PATTERN_INT, oFileExt)
End If
End If
End While
While ContainsPatternAndValue(oResult, PATTERN_INT, INT_VALUE_FILE_DATE)
If Not IsNothing(_handled_File) Then
If File.Exists(_handled_File) Then
Dim oCreationDate As DateTime = File.GetCreationTime(_handled_File)
Dim oDateOnlyString As String = oCreationDate.ToString("yyyy-MM-dd")
oResult = ReplacePattern(oResult, PATTERN_INT, oDateOnlyString)
End If
End If
End While
Return oResult Return oResult
Catch ex As Exception Catch ex As Exception
_Logger.Error(ex) _Logger.Error(ex)