Compare commits
6 Commits
6ed636bca0
...
36fe39ee66
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36fe39ee66 | ||
|
|
ddc11b62a5 | ||
|
|
7ba516fcd1 | ||
|
|
05a92c3181 | ||
|
|
7d63718e96 | ||
|
|
8af67ef883 |
@@ -437,7 +437,7 @@ Public Class MSSQLServer
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Warn("ExecuteNonQueryWithConnectionObject: Error in ExecuteNonQueryWithConnectionObject while executing command: [{0}]-[{1}]", SqlCommand, SqlConnection.ConnectionString)
|
||||
Logger.Warn("ExecuteNonQueryWithConnectionObject: Error in ExecuteNonQueryWithConnectionObject while executing command: [{0}]", pSqlCommandObject)
|
||||
Return False
|
||||
Finally
|
||||
MaybeCommitTransaction(oTransaction, pTransactionMode)
|
||||
|
||||
@@ -127,7 +127,7 @@ Public Class Oracle
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetDatatable(pSQLCommand As String, pTimeout As Integer) As DataTable Implements IDatabase.GetDatatable
|
||||
Public Function GetDatatable(pSQLCommand As String, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As DataTable Implements IDatabase.GetDatatable
|
||||
Try
|
||||
Using oConnection = GetConnection(CurrentConnectionString)
|
||||
Dim oSQLCommand As OracleCommand
|
||||
@@ -151,8 +151,8 @@ Public Class Oracle
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetDatatable(pSQLCommand As String) As DataTable Implements IDatabase.GetDatatable
|
||||
Return GetDatatable(pSQLCommand, _Timeout)
|
||||
Public Function GetDatatable(SqlCommand As SqlClient.SqlCommand, Optional Timeout As Integer = 120) As DataTable Implements IDatabase.GetDatatable
|
||||
Throw New NotImplementedException()
|
||||
End Function
|
||||
|
||||
Public Function ExecuteNonQuery(pSQLCommand As String, pTimeout As Integer) As Boolean Implements IDatabase.ExecuteNonQuery
|
||||
@@ -250,4 +250,6 @@ Public Class Oracle
|
||||
Return "Invalid ConnectionString"
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
@@ -42,7 +42,7 @@ Namespace SyncUsers
|
||||
End Try
|
||||
|
||||
For Each oUser In Users
|
||||
Dim oUserId As Int64
|
||||
Dim oUserId As Long
|
||||
Dim oUserExists As Boolean
|
||||
|
||||
' Check if user already exists
|
||||
@@ -68,7 +68,7 @@ Namespace SyncUsers
|
||||
_logger.Debug("Creating new user for [{0}]", oUser)
|
||||
oUserId = CreateUser(oUser)
|
||||
_logger.Debug("User created with Id [{0}]", oUserId)
|
||||
_logger.Info("Added new User [{0}]", oUser.samAccountName)
|
||||
_logger.Info("Added new User [{0}]", oUser)
|
||||
|
||||
oCreatedUsers.Add(oUser)
|
||||
Else
|
||||
@@ -76,7 +76,7 @@ Namespace SyncUsers
|
||||
oUserId = UpdateUser(oUser)
|
||||
If oUserId <> 0 Then
|
||||
_logger.Debug("User created with Id [{0}]", oUserId)
|
||||
_logger.Info("Updated User [{0}]", oUser.samAccountName)
|
||||
_logger.Info("Updated User [{0}]", oUser)
|
||||
|
||||
oUpdatedUsers.Add(oUser)
|
||||
End If
|
||||
@@ -84,7 +84,7 @@ Namespace SyncUsers
|
||||
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
_logger.Warn("Could Not create/update user [{0}]. Skipping.", oUser.samAccountName)
|
||||
_logger.Warn("Could Not create/update user [{0}]. Skipping.", oUser)
|
||||
Continue For
|
||||
End Try
|
||||
|
||||
@@ -99,7 +99,7 @@ Namespace SyncUsers
|
||||
' Add the user to group
|
||||
Try
|
||||
If AddUserToGroup(oUserId, oGroupId) Then
|
||||
_logger.Info("User [{0}] added to group [{1}]", oUser.samAccountName, GroupName)
|
||||
_logger.Info("User [{0}] added to group [{1}]", oUser, GroupName)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
@@ -175,7 +175,8 @@ Namespace SyncUsers
|
||||
Dim oSQL As String = $"SELECT GUID FROM TBDD_USER WHERE UPPER(USERNAME) = UPPER('{UserName}')"
|
||||
Dim oUserId = _mssql.GetScalarValue(oSQL)
|
||||
|
||||
If IsDBNull(oUserId) OrElse oUserId = 0 Then
|
||||
If IsDBNull(oUserId) OrElse IsNothing(oUserId) OrElse oUserId = 0 Then
|
||||
_logger.Debug("User [{0}] does not exist", UserName)
|
||||
Return 0
|
||||
End If
|
||||
|
||||
@@ -194,9 +195,15 @@ Namespace SyncUsers
|
||||
End If
|
||||
|
||||
Dim oUserId As Integer = GetUserId(User.samAccountName)
|
||||
_logger.Debug("UserId of User [{0}] is [{1}]", User, oUserId)
|
||||
|
||||
If oUserId = 0 Then
|
||||
Dim oSQL As String = $"INSERT INTO TBDD_USER (PRENAME, NAME, USERNAME, EMAIL, ADDED_WHO) VALUES ('{User?.GivenName}', '{User?.Surname?.Replace("'", "''")}', UPPER('{User?.samAccountName?.Replace("'", "''")}'), '{User?.Email?.Replace("'", "''")}', '{ADDED_WHO}')"
|
||||
Dim oPrename = User.GivenName.EscapeForSQL()
|
||||
Dim oSurname = User.Surname.EscapeForSQL()
|
||||
Dim oUsername = User.samAccountName.EscapeForSQL()
|
||||
Dim oEmail = User.Email.EscapeForSQL()
|
||||
|
||||
Dim oSQL As String = $"INSERT INTO TBDD_USER (PRENAME, NAME, USERNAME, EMAIL, ADDED_WHO) VALUES ('{oPrename}', '{oSurname}', UPPER('{oUsername}'), '{oEmail}', '{ADDED_WHO}')"
|
||||
Dim oResult = _mssql.ExecuteNonQuery(oSQL)
|
||||
|
||||
If oResult = True Then
|
||||
@@ -230,11 +237,11 @@ Namespace SyncUsers
|
||||
Dim oUserId As Integer = GetUserId(User.samAccountName)
|
||||
If Not IsNothing(oUserId) Then
|
||||
If oUserId > 0 Then
|
||||
Dim oGivenName As String = EscapeQuotes(User.GivenName)
|
||||
Dim oSurname As String = EscapeQuotes(User.Surname)
|
||||
Dim oEmail As String = EscapeQuotes(User.Email)
|
||||
Dim oPrename = User.GivenName.EscapeForSQL()
|
||||
Dim oSurname = User.Surname.EscapeForSQL()
|
||||
Dim oEmail = User.Email.EscapeForSQL()
|
||||
|
||||
Dim oSQL As String = $"UPDATE TBDD_USER SET PRENAME = '{oGivenName}', NAME = '{oSurname}', EMAIL = '{oEmail}', CHANGED_WHO = '{ADDED_WHO}' WHERE GUID = {oUserId}"
|
||||
Dim oSQL As String = $"UPDATE TBDD_USER SET PRENAME = '{oPrename}', NAME = '{oSurname}', EMAIL = '{oEmail}', CHANGED_WHO = '{ADDED_WHO}' WHERE GUID = {oUserId}"
|
||||
Dim oResult = _mssql.ExecuteNonQuery(oSQL)
|
||||
|
||||
If oResult = True Then
|
||||
@@ -256,11 +263,6 @@ Namespace SyncUsers
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function EscapeQuotes(pString As String)
|
||||
Dim oString = Utils.NotNull(pString, String.Empty)
|
||||
Return oString.Replace("'", "''")
|
||||
End Function
|
||||
|
||||
Public Sub AddCustomAttributesToUser(User As ADUser, UserId As Integer) Implements ISyncUsers.AddCustomAttributesToUser
|
||||
Dim oCustomAttributes = User.CustomAttributes
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
|
||||
<Assembly: AssemblyCompany("Digital Data")>
|
||||
<Assembly: AssemblyProduct("Modules.Interfaces")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2022")>
|
||||
<Assembly: AssemblyTrademark("1.8.0.0")>
|
||||
<Assembly: AssemblyTrademark("1.8.1.0")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.8.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.8.0.0")>
|
||||
<Assembly: AssemblyVersion("1.8.1.0")>
|
||||
<Assembly: AssemblyFileVersion("1.8.1.0")>
|
||||
|
||||
@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
|
||||
<Assembly: AssemblyCompany("")>
|
||||
<Assembly: AssemblyProduct("Language")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2022")>
|
||||
<Assembly: AssemblyTrademark("1.6.1.0")>
|
||||
<Assembly: AssemblyTrademark("1.6.2.0")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.6.1.0")>
|
||||
<Assembly: AssemblyFileVersion("1.6.1.0")>
|
||||
<Assembly: AssemblyVersion("1.6.2.0")>
|
||||
<Assembly: AssemblyFileVersion("1.6.2.0")>
|
||||
|
||||
@@ -20,7 +20,6 @@ Public Module StringEx
|
||||
''' <returns>The escaped string.</returns>
|
||||
<Extension()>
|
||||
Public Function EscapeForSQL(pString As String) As String
|
||||
If String.IsNullOrEmpty(pString) Then Return pString
|
||||
Return pString.Replace("'", "''")
|
||||
Return Utils.NotNull(pString, String.Empty).Replace("'", "''")
|
||||
End Function
|
||||
End Module
|
||||
|
||||
Reference in New Issue
Block a user