Refactor session logout logic into helper method
Extracted duplicated session logout code into a new private method, LogoutCurrentSession. This method is now used in both GetWMSessionAsUser and GetWMSession to improve code reuse and maintainability. Exception handling for session logout remains silent to avoid issues with already-terminated sessions.
This commit is contained in:
@@ -49,7 +49,20 @@ Public Class ClassWindream_allgemein
|
||||
' Process.GetCurrentProcess.Kill()
|
||||
End If
|
||||
End Sub
|
||||
Private Sub LogoutCurrentSession()
|
||||
If Not IsNothing(CURRENToWMSession) Then
|
||||
Try
|
||||
CURRENToWMSession.Logout()
|
||||
Catch
|
||||
' ignorieren – Session war evtl. schon tot
|
||||
End Try
|
||||
CURRENToWMSession = Nothing
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Function GetWMSessionAsUser(Domain, ServerName, UserName, Password)
|
||||
LogoutCurrentSession()
|
||||
|
||||
Dim SessionAsUser
|
||||
Dim aConnect, aUserId, aSession
|
||||
On Error Resume Next
|
||||
@@ -143,14 +156,7 @@ Public Class ClassWindream_allgemein
|
||||
|
||||
End Function
|
||||
Private Function GetWMSession()
|
||||
If Not IsNothing(CURRENToWMSession) Then
|
||||
Try
|
||||
CURRENToWMSession.Logout()
|
||||
Catch
|
||||
' ignorieren – Session war evtl. schon tot
|
||||
End Try
|
||||
CURRENToWMSession = Nothing
|
||||
End If
|
||||
LogoutCurrentSession()
|
||||
|
||||
Try
|
||||
Try
|
||||
|
||||
Reference in New Issue
Block a user