Interfaces/ActiveDirectory: make sync users more resilient form missing attrs
This commit is contained in:
@@ -47,10 +47,10 @@ Namespace SyncUsers
|
||||
|
||||
' Check if user already exists
|
||||
Try
|
||||
_logger.Debug("Checking if user {0} exists", oUser)
|
||||
_logger.Debug("Checking if user [{0}] exists", oUser)
|
||||
oUserId = GetUserId(oUser.samAccountName)
|
||||
oUserExists = oUserId > 0
|
||||
_logger.Debug("User {0} exists in database: {1}", oUser, oUserExists)
|
||||
_logger.Debug("User [{0}] exists in database: [{1}]", oUser, oUserExists)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
_logger.Warn("Could not get UserId for user. Skipping.")
|
||||
@@ -187,9 +187,15 @@ Namespace SyncUsers
|
||||
|
||||
Private Function CreateUser(User As ADUser) As Integer Implements ISyncUsers.CreateUser
|
||||
Try
|
||||
If User Is Nothing Then
|
||||
_logger.Warn("Argument [User] is nothing. Exiting.")
|
||||
Throw New ArgumentNullException("User")
|
||||
End If
|
||||
|
||||
Dim oUserId As Integer = GetUserId(User.samAccountName)
|
||||
|
||||
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 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 oResult = _mssql.ExecuteNonQuery(oSQL)
|
||||
|
||||
If oResult = True Then
|
||||
|
||||
Reference in New Issue
Block a user