LogON LogOFF werden protokoliert

This commit is contained in:
ms
2022-12-28 09:58:58 +01:00
parent 18e00e475d
commit d694d26d19
18 changed files with 955 additions and 79 deletions

41
Class2.vb Normal file
View File

@@ -0,0 +1,41 @@
Public Class Class1
Public sAppPath As String = Application.StartupPath
'Public Shared DBConString As String = "Server=NBMIESENBECK\SPIELWIESE;Initial Catalog=Doku;User ID=sa;Password=verag#3;Connection Timeout=5;"
Public Shared DBConstringDev As String = "Server=DEVELOPER.verag.ost.dmn\DEVSQL;Initial Catalog=Doku;User ID=sa;Password=BmWr501956;Connection Timeout=5;"
Public Shared DBADMINBuchhaltung As String = "Data Source=SQLGuide01.verag.ost.dmn;Initial Catalog=ADMIN;Integrated Security=false;User ID=sa;Password=BmWr501956;"
Public Shared DBAdmin As String = "[SQLGuide01.verag.ost.dmn].ADMIN"
Public Shared DBDoku As String = "Server=SQLGuide01.verag.ost.dmn\Verag;Initial Catalog=Doku;User ID=sa;Password=BmWr501956;Connection Timeout=5;"
'Public Shared DBDoku As String = "Server=dokusql.verag.ost.dmn\sqlexpress;Initial Catalog=Doku;User ID=sa;Password=BmWr501956;Connection Timeout=5;"
Public Shared DBDokuTest As String = "Server=DEVELOPER.verag.ost.dmn\DEVSQL;Initial Catalog=Doku;User ID=sa;Password=BmWr501956;Connection Timeout=5;"
'Public Shared FilePath As String = "\\192.168.0.253\backup\temp_Sebastian\Spielwiese\Doku"
Public Shared FilePath As String ' = "\\192.168.0.90\f\EDV-Wartung\Dokumentation"
Public Shared Absender As String = "Absender Standard"
'Public Shared sAppPath As String = Application.StartupPath
Public Shared DBConString As String = DBDoku
Public Shared Standorte As New List(Of String)
Public Shared AlleStandorte As New List(Of String)
Public Shared LoggedOnUser As New cBenutzer
Public Shared LoggedOnUserisAdmin As Boolean = False
Public Shared DebugMode As Boolean = False
Public Shared DebugText As String = ""
Public Shared GroupUsers As List(Of cBenutzer)
Public Shared dtSuchergebnis As DataTable
Public Shared TeamviewerToken As String = "6920997-rtea7sZy35Ujw2Erm3OP"
Public Shared HostList As New List(Of String)
Public Shared TerminalServerList As New List(Of String)
Public Shared Function DBNull2emptyString(totest As Object)
If IsDBNull(totest) Then
Return ""
Else
Return totest
End If
End Function
End Class

50
Main.Designer.vb generated
View File

@@ -28,17 +28,20 @@ Partial Class TSUserReporter
Me.NotifyIcon1 = New System.Windows.Forms.NotifyIcon(Me.components) Me.NotifyIcon1 = New System.Windows.Forms.NotifyIcon(Me.components)
Me.ContextMenuStripIcon = New System.Windows.Forms.ContextMenuStrip(Me.components) Me.ContextMenuStripIcon = New System.Windows.Forms.ContextMenuStrip(Me.components)
Me.ReportToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.ReportToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.BeendenToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.ReporterAnzeigenToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.ReporterAnzeigenToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.ToolStripSeparator1 = New System.Windows.Forms.ToolStripSeparator() Me.ToolStripSeparator1 = New System.Windows.Forms.ToolStripSeparator()
Me.BeendenToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.Label1 = New System.Windows.Forms.Label() Me.Label1 = New System.Windows.Forms.Label()
Me.UpdateTimer = New System.Windows.Forms.Timer(Me.components)
Me.btnTest = New System.Windows.Forms.Button()
Me.Button1 = New System.Windows.Forms.Button()
Me.cmdMini = New System.Windows.Forms.Button() Me.cmdMini = New System.Windows.Forms.Button()
Me.ContextMenuStripIcon.SuspendLayout() Me.ContextMenuStripIcon.SuspendLayout()
Me.SuspendLayout() Me.SuspendLayout()
' '
'cmdGetLocalUser 'cmdGetLocalUser
' '
Me.cmdGetLocalUser.Location = New System.Drawing.Point(12, 123) Me.cmdGetLocalUser.Location = New System.Drawing.Point(12, 161)
Me.cmdGetLocalUser.Name = "cmdGetLocalUser" Me.cmdGetLocalUser.Name = "cmdGetLocalUser"
Me.cmdGetLocalUser.Size = New System.Drawing.Size(199, 23) Me.cmdGetLocalUser.Size = New System.Drawing.Size(199, 23)
Me.cmdGetLocalUser.TabIndex = 0 Me.cmdGetLocalUser.TabIndex = 0
@@ -64,12 +67,6 @@ Partial Class TSUserReporter
Me.ReportToolStripMenuItem.Size = New System.Drawing.Size(169, 22) Me.ReportToolStripMenuItem.Size = New System.Drawing.Size(169, 22)
Me.ReportToolStripMenuItem.Text = "Report" Me.ReportToolStripMenuItem.Text = "Report"
' '
'BeendenToolStripMenuItem
'
Me.BeendenToolStripMenuItem.Name = "BeendenToolStripMenuItem"
Me.BeendenToolStripMenuItem.Size = New System.Drawing.Size(169, 22)
Me.BeendenToolStripMenuItem.Text = "Beenden"
'
'ReporterAnzeigenToolStripMenuItem 'ReporterAnzeigenToolStripMenuItem
' '
Me.ReporterAnzeigenToolStripMenuItem.Name = "ReporterAnzeigenToolStripMenuItem" Me.ReporterAnzeigenToolStripMenuItem.Name = "ReporterAnzeigenToolStripMenuItem"
@@ -81,6 +78,12 @@ Partial Class TSUserReporter
Me.ToolStripSeparator1.Name = "ToolStripSeparator1" Me.ToolStripSeparator1.Name = "ToolStripSeparator1"
Me.ToolStripSeparator1.Size = New System.Drawing.Size(166, 6) Me.ToolStripSeparator1.Size = New System.Drawing.Size(166, 6)
' '
'BeendenToolStripMenuItem
'
Me.BeendenToolStripMenuItem.Name = "BeendenToolStripMenuItem"
Me.BeendenToolStripMenuItem.Size = New System.Drawing.Size(169, 22)
Me.BeendenToolStripMenuItem.Text = "Beenden"
'
'Label1 'Label1
' '
Me.Label1.AutoSize = True Me.Label1.AutoSize = True
@@ -90,6 +93,30 @@ Partial Class TSUserReporter
Me.Label1.TabIndex = 2 Me.Label1.TabIndex = 2
Me.Label1.Text = "Label1" Me.Label1.Text = "Label1"
' '
'UpdateTimer
'
Me.UpdateTimer.Enabled = True
Me.UpdateTimer.Interval = 300000
'
'btnTest
'
Me.btnTest.Location = New System.Drawing.Point(136, 132)
Me.btnTest.Name = "btnTest"
Me.btnTest.Size = New System.Drawing.Size(75, 23)
Me.btnTest.TabIndex = 4
Me.btnTest.Text = "Test"
Me.btnTest.UseVisualStyleBackColor = True
Me.btnTest.Visible = False
'
'Button1
'
Me.Button1.Image = Global.TSUserReporter.My.Resources.Resources.Print20x20
Me.Button1.Location = New System.Drawing.Point(168, 38)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(43, 23)
Me.Button1.TabIndex = 5
Me.Button1.UseVisualStyleBackColor = True
'
'cmdMini 'cmdMini
' '
Me.cmdMini.Image = Global.TSUserReporter.My.Resources.Resources.del Me.cmdMini.Image = Global.TSUserReporter.My.Resources.Resources.del
@@ -103,8 +130,10 @@ Partial Class TSUserReporter
' '
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(219, 157) Me.ClientSize = New System.Drawing.Size(219, 196)
Me.ControlBox = False Me.ControlBox = False
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.btnTest)
Me.Controls.Add(Me.cmdMini) Me.Controls.Add(Me.cmdMini)
Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.cmdGetLocalUser) Me.Controls.Add(Me.cmdGetLocalUser)
@@ -128,4 +157,7 @@ Partial Class TSUserReporter
Friend WithEvents BeendenToolStripMenuItem As ToolStripMenuItem Friend WithEvents BeendenToolStripMenuItem As ToolStripMenuItem
Friend WithEvents Label1 As Label Friend WithEvents Label1 As Label
Friend WithEvents cmdMini As Button Friend WithEvents cmdMini As Button
Friend WithEvents UpdateTimer As Timer
Friend WithEvents btnTest As Button
Friend WithEvents Button1 As Button
End Class End Class

View File

@@ -1256,6 +1256,9 @@
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
</value> </value>
</data> </data>
<metadata name="UpdateTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>306, 17</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
AAABAAEAgIAAAAEAIAAoCAEAFgAAACgAAACAAAAAAAEAAAEAIAAAAAAAAAABAMMOAADDDgAAAAAAAAAA AAABAAEAgIAAAAEAIAAoCAEAFgAAACgAAACAAAAAAAEAAAEAIAAAAAAAAAABAMMOAADDDgAAAAAAAAAA

275
Main.vb
View File

@@ -1,10 +1,31 @@
Public Class TSUserReporter Imports System.Environment
Imports System.IO
Public Class TSUserReporter
Dim lastupdate As DateTime Dim lastupdate As DateTime
Dim StartTime As DateTime
Public sNetlogon As String = "\\verag.ost.dmn\NETLOGON"
Public Printer As New List(Of Drucker)
Dim Standarddrucker As New Drucker("", "")
Dim Bondrucker As New Drucker("", "")
Public Message As String
Dim ThinClient As String
Dim isTS As Boolean = False
Dim ID As String = ""
Private Sub TSUserReporter_Load(sender As Object, e As EventArgs) Handles MyBase.Load Private Sub TSUserReporter_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Visible = False
StartTime = Date.Now
Routine() Routine()
SetPrinterRoutine()
FillLabel() FillLabel()
ID = StartTime.ToString("dd.MM HH:mm:ss") & cRes.LocalUser.BenutzeranmeldeName
LogLogOn()
End Sub End Sub
Private Sub cmdGetLocalUser_Click(sender As Object, e As EventArgs) Handles cmdGetLocalUser.Click Private Sub cmdGetLocalUser_Click(sender As Object, e As EventArgs) Handles cmdGetLocalUser.Click
@@ -12,13 +33,49 @@
End Sub End Sub
Sub Routine() Sub Routine()
cRes.LocalUser.FillWithLoggedOnUser() Try
cRes.LocalTeamviewerID = getregkey() cRes.LocalUser.FillWithLoggedOnUser(True)
cRes.LocalTeamviewerID = getregkey()
cRes.LocalDomUser.getDomUserByBenutzerAnmeldename(Environment.UserDomainName, Environment.UserName)
Report() isTS = cRes.LocalUser.Hostname Like "TS*"
FillLabel() 'isTS = True
'MsgBox(isTS)
Report()
' FillLabel()
If cRes.LocalDomUser.du_autologoff = True And cRes.DisableAutoLogoff = False Then
CheckAutoLogOffAndIfthenAutoLogOff()
End If
Catch ex As Exception
'MsgBox(ex.Message)
End Try
End Sub End Sub
Sub LogLogOn()
'Make ID
Try
cSQL.InsertSQL("TbL_LogOnLogOffLog", "(Benutzeranmeldename, LogOn, TSServer, LogOff, ID) VALUES (
'" & cRes.LocalUser.BenutzeranmeldeName & "',
'" & Date.Now & "',
'" & cRes.LocalUser.Hostname & "',
' ',
'" & ID & "')")
Catch ex As Exception
End Try
End Sub
Function CheckAutoLogOffAndIfthenAutoLogOff()
If cRes.LocalDomUser.du_autologofftime.TimeOfDay < DateTime.Now.TimeOfDay And DateTime.Now.TimeOfDay < cRes.LocalDomUser.du_autologofftime.AddMinutes(15).TimeOfDay Then
Dim frm As New frmLogOff
frm.Show()
End If
End Function
Function getregkey() Function getregkey()
Dim Reg As String = Nothing Dim Reg As String = Nothing
If My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\TeamViewer", "ClientIDOfTSUser", Nothing) Is Nothing Then If My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\TeamViewer", "ClientIDOfTSUser", Nothing) Is Nothing Then
@@ -31,36 +88,73 @@
End Function End Function
Function Report() Function Report()
lastupdate = Date.Now Try
Dim ds As New DataSet lastupdate = Date.Now
cSQL.SQL2DS("select * from TbL_TSSitzungen where Benutzeranmeldename = '" & cRes.LocalUser.BenutzeranmeldeName & " ' ", ds) Dim ds As New DataSet
If Not ds.Tables(0).Rows.Count = 0 Then cSQL.SQL2DS("select * from TbL_TSSitzungen where Benutzeranmeldename = '" & cRes.LocalUser.BenutzeranmeldeName & " ' AND TSServer = '" & cRes.LocalUser.Hostname & "'", ds)
RemoveSitzung() If Not ds.Tables(0).Rows.Count = 0 Then
End If RemoveSitzung()
cSQL.InsertSQL("TbL_TSSitzungen", "(Benutzeranmeldename, Name, TeamviewerID, LastReport, TSServer) VALUES ( End If
If isTS Then
Dim ds2 As New DataSet
cSQL.SQL2DS("select * from [TbL_ThinClients] where Benutzeranmeldename = '" & cRes.LocalUser.BenutzeranmeldeName & "'", ds2)
'cSQL.SQL2DS("select * from [TbL_ThinClients] where Benutzeranmeldename = 'veragost\tw' ", ds2)
If Not ds2.Tables(0).Rows.Count = 0 Then
ThinClient = ds2.Tables(0).Rows(0).Item("ClientName").ToString
End If
End If
'MsgBox(ThinClient)
cSQL.InsertSQL("TbL_TSSitzungen", "(Benutzeranmeldename, Name, TeamviewerID, LastReport, Domain, Company, LastLogon, TSServer) VALUES (
'" & cRes.LocalUser.BenutzeranmeldeName & "', '" & cRes.LocalUser.BenutzeranmeldeName & "',
'" & cRes.LocalUser.Name & "', '" & cRes.LocalUser.Name & "',
'" & cRes.LocalTeamviewerID & "', '" & cRes.LocalTeamviewerID & "',
'" & Date.Now & "', '" & Date.Now & "',
'" & cRes.LocalUser.Domäne & "',
'" & cRes.LocalUser.Company & "',
'" & StartTime.ToString("dd.MM HH:mm") & "',
'" & cRes.LocalUser.Hostname & "')") '" & cRes.LocalUser.Hostname & "')")
Catch ex As Exception
MsgBox("Report():" & vbCrLf & ex.Message)
End Try
SetUserEnviroment()
End Function End Function
Function FillLabel() Function FillLabel()
Label1.Text = "" Label1.Text = ""
Label1.Text &= cRes.LocalUser.BenutzeranmeldeName & vbCrLf Label1.Text &= cRes.LocalUser.BenutzeranmeldeName & vbCrLf
Label1.Text &= cRes.LocalUser.Name & vbCrLf Label1.Text &= cRes.LocalUser.Name & vbCrLf
Label1.Text &= cRes.LocalUser.Hostname & vbCrLf Label1.Text &= "Hostname:" & cRes.LocalUser.Hostname & vbCrLf
Label1.Text &= "ThinClient:" & ThinClient& & vbCrLf
Label1.Text &= "TeamviewerID: " & cRes.LocalTeamviewerID & vbCrLf Label1.Text &= "TeamviewerID: " & cRes.LocalTeamviewerID & vbCrLf
Label1.Text &= vbCrLf Label1.Text &= vbCrLf
Label1.Text &= "Letzte Aktualisierung:" & vbCrLf Label1.Text &= "Letzte Aktualisierung:" & vbCrLf
Label1.Text &= lastupdate Label1.Text &= lastupdate & vbCrLf
Label1.Text &= Standarddrucker.Druckername & vbCrLf
Label1.Text &= Bondrucker.Druckername & vbCrLf & vbCrLf
Label1.Text &= Message
End Function End Function
Sub RemoveSitzung() Sub RemoveSitzung()
cSQL.DeleteSQL("TbL_TSSitzungen", "Benutzeranmeldename = '" & cRes.LocalUser.BenutzeranmeldeName & " ' ") cSQL.DeleteSQL("TbL_TSSitzungen", "Benutzeranmeldename = '" & cRes.LocalUser.BenutzeranmeldeName & " ' AND TSServer = '" & cRes.LocalUser.Hostname & "'")
End Sub
Sub LogLogOff()
Dim where As String = "ID = '" & ID & "'"
Dim Values As String = "LogOff ='" & Date.Now & "'"
Try
cSQL.UpdateSQL("TbL_LogOnLogOffLog", Values, where)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub End Sub
Private Sub TSUserReporter_Closed(sender As Object, e As EventArgs) Handles Me.Closed Private Sub TSUserReporter_Closed(sender As Object, e As EventArgs) Handles Me.Closed
LogLogOff()
RemoveSitzung() RemoveSitzung()
End Sub End Sub
@@ -82,4 +176,155 @@
Me.WindowState = WindowState.Minimized Me.WindowState = WindowState.Minimized
Me.Hide() Me.Hide()
End Sub End Sub
Private Sub UpdateTimer_Tick(sender As Object, e As EventArgs) Handles UpdateTimer.Tick
Routine()
End Sub
Private Sub btnTest_Click(sender As Object, e As EventArgs) Handles btnTest.Click
'If LoadDefaultPrinter(cRes.LocalUser.Hostname) Then
' SetDefaultPrinter()
' MsgBox(Drucker)
'End If
End Sub
Function SetUserEnviroment()
Try
Environment.SetEnvironmentVariable("PC_SERVER", "pbx3.flashnet.at", EnvironmentVariableTarget.User)
Environment.SetEnvironmentVariable("PC_USER", cRes.LocalDomUser.mit_username & "@verag", EnvironmentVariableTarget.User)
'Environment.SetEnvironmentVariable("PC_PASS", cRes.LocalDomUser.mit_pwd, EnvironmentVariableTarget.User)
' Environment.SetEnvironmentVariable("PC_USE_CUSTOM_NOTIFICATIONS_AS_DEFAULT", "ENA", EnvironmentVariableTarget.User)
' MsgBox(Environment.GetEnvironmentVariable("PC_SErVER"))
Message = "UserEnv eingetragen."
Catch ex As Exception
Message = ex.Message
End Try
End Function
Public Function LoadDefaultPrinter(ByVal Hostname As String)
Dim PrintINI As String = ""
'If isTS Then
' PrintINI = "C:\Users\" & cRes.LocalUser.Username & "\Documents\AVISO_OPTIONS.txt"
' Try
' Dim lines = IO.File.ReadAllLines(PrintINI)
' Dim colCount = lines.First.Split(":"c).Length
' For Each line In lines
' Dim objFields = From field In line.Split(":"c)
' 'Select Case objFields(0).ToString
' ' Case Benutzername
' If String.Compare("PRINTER", objFields(0).ToString, True) = 0 Then
' Drucker = objFields(1).ToString
' '_ConString = objFields(2).ToString
' Return True
' Exit Function
' End If
' ' End Select
' Next
' Return False
' Catch ex As Exception
' ' MsgBox("Fehler beim Lesen TSAnmeldung.ini: " & vbCrLf & ex.Message)
' End Try
' Else
PrintINI = sNetlogon & "\ClientDrucker.ini"
Printer.Clear()
Try
Dim lines = IO.File.ReadAllLines(PrintINI)
Dim colCount = lines.First.Split(";"c).Length
For Each line In lines
Dim objFields = From field In line.Split(";"c)
'Select Case objFields(0).ToString
' Case Benutzername
If String.Compare(Hostname, objFields(0).ToString, True) = 0 Then
Dim p As New Drucker(objFields(1).ToString, objFields(2).ToString)
Printer.Add(p)
'_ConString = objFields(2).ToString
' Return True
' Exit Function
End If
' End Select
Next
If Printer.Count = 0 Then
Dim p As New Drucker("kein Drucker hinterlegt", "")
Printer.Add(p)
Return False
Else
Return True
End If
Catch ex As Exception
Return False
' MsgBox("Fehler beim Lesen TSAnmeldung.ini: " & vbCrLf & ex.Message)
End Try
' End If
End Function
Public Function SetDefaultPrinter()
For Each p As Drucker In Printer
If p.Druckertype = "" Or p.Druckertype = "Standard" Then
Standarddrucker = p
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device", p.Druckername)
ElseIf p.Druckertype = "Bon" Then
Bondrucker = p
End If
Next
writeoutAVISO_OPTIONS()
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
SetPrinterRoutine()
FillLabel()
End Sub
Sub SetPrinterRoutine()
If isTS Then
If LoadDefaultPrinter(ThinClient) Then
SetDefaultPrinter()
End If
Else
If LoadDefaultPrinter(cRes.LocalUser.Hostname) Then
SetDefaultPrinter()
End If
End If
End Sub
Sub writeoutAVISO_OPTIONS()
Dim PrintINI As String = "C:\Users\" & cRes.LocalUser.Username & "\Documents\AVISO_OPTIONS.txt"
Dim Text As String = ""
If Printer.Count = 0 Then
Text = ""
Else
Text = "PRINTER:" & Standarddrucker.Druckername & vbCrLf
Text &= "BON:" & Bondrucker.Druckername
End If
My.Computer.FileSystem.WriteAllText(PrintINI, Text, False)
End Sub
End Class
Public Class Drucker
Property Druckername As String = ""
Property Druckertype As String = ""
Sub New(a As String, b As String)
Me.Druckername = a
Me.Druckertype = b
End Sub
End Class End Class

View File

@@ -25,7 +25,7 @@ Namespace My
Public Sub New() Public Sub New()
MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
Me.IsSingleInstance = false Me.IsSingleInstance = false
Me.EnableVisualStyles = true Me.EnableVisualStyles = false
Me.SaveMySettingsOnExit = true Me.SaveMySettingsOnExit = true
Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
End Sub End Sub

View File

@@ -4,7 +4,7 @@
<MainForm>TSUserReporter</MainForm> <MainForm>TSUserReporter</MainForm>
<SingleInstance>false</SingleInstance> <SingleInstance>false</SingleInstance>
<ShutdownMode>0</ShutdownMode> <ShutdownMode>0</ShutdownMode>
<EnableVisualStyles>true</EnableVisualStyles> <EnableVisualStyles>false</EnableVisualStyles>
<AuthenticationMode>0</AuthenticationMode> <AuthenticationMode>0</AuthenticationMode>
<SaveMySettingsOnExit>true</SaveMySettingsOnExit> <SaveMySettingsOnExit>true</SaveMySettingsOnExit>
</MyApplicationData> </MyApplicationData>

View File

@@ -69,5 +69,15 @@ Namespace My.Resources
Return CType(obj,System.Drawing.Bitmap) Return CType(obj,System.Drawing.Bitmap)
End Get End Get
End Property End Property
'''<summary>
''' Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
'''</summary>
Friend ReadOnly Property Print20x20() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("Print20x20", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
End Module End Module
End Namespace End Namespace

View File

@@ -121,4 +121,7 @@
<data name="del" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="del" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\del.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\del.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="Print20x20" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Print20x20.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root> </root>

View File

@@ -1,10 +1,10 @@
'------------------------------------------------------------------------------ '------------------------------------------------------------------------------
' <auto-generated> ' <auto-generated>
' This code was generated by a tool. ' Dieser Code wurde von einem Tool generiert.
' Runtime Version:4.0.30319.42000 ' Laufzeitversion:4.0.30319.42000
' '
' Changes to this file may cause incorrect behavior and will be lost if ' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
' the code is regenerated. ' der Code erneut generiert wird.
' </auto-generated> ' </auto-generated>
'------------------------------------------------------------------------------ '------------------------------------------------------------------------------
@@ -14,26 +14,26 @@ Option Explicit On
Namespace My Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _ <Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0"), _ Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.3.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
#Region "My.Settings Auto-Save Functionality" #Region "Automatische My.Settings-Speicherfunktion"
#If _MyType = "WindowsForms" Then #If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then If My.Application.SaveMySettingsOnExit Then
My.Settings.Save() My.Settings.Save()
End If End If
End Sub End Sub
#End If #End If
#End Region #End Region
@@ -41,14 +41,14 @@ Namespace My
Get Get
#If _MyType = "WindowsForms" Then #If _MyType = "WindowsForms" Then
If Not addedHandler Then If Not addedHandler Then
SyncLock addedHandlerLockObject SyncLock addedHandlerLockObject
If Not addedHandler Then If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True addedHandler = True
End If End If
End SyncLock End SyncLock
End If End If
#End If #End If
Return defaultInstance Return defaultInstance
End Get End Get
@@ -58,12 +58,12 @@ End Namespace
Namespace My Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _ <Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _ Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _ Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Module MySettingsProperty Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _ <Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.TSUserReporter.My.MySettings Friend ReadOnly Property Settings() As Global.TSUserReporter.My.MySettings
Get Get
Return Global.TSUserReporter.My.MySettings.Default Return Global.TSUserReporter.My.MySettings.Default

BIN
Resources/Print20x20.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@@ -78,12 +78,14 @@
<Reference Include="System.DirectoryServices" /> <Reference Include="System.DirectoryServices" />
<Reference Include="System.DirectoryServices.AccountManagement" /> <Reference Include="System.DirectoryServices.AccountManagement" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
<Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Import Include="Microsoft.VisualBasic" /> <Import Include="Microsoft.VisualBasic" />
@@ -100,8 +102,16 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="cBenutzer.vb" /> <Compile Include="cBenutzer.vb" />
<Compile Include="cDomUser.vb" />
<Compile Include="Class2.vb" />
<Compile Include="cRes.vb" /> <Compile Include="cRes.vb" />
<Compile Include="cSQL.vb" /> <Compile Include="cSQL.vb" />
<Compile Include="frmLogOff.Designer.vb">
<DependentUpon>frmLogOff.vb</DependentUpon>
</Compile>
<Compile Include="frmLogOff.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="Main.vb"> <Compile Include="Main.vb">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@@ -126,6 +136,9 @@
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="frmLogOff.resx">
<DependentUpon>frmLogOff.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Main.resx"> <EmbeddedResource Include="Main.resx">
<DependentUpon>Main.vb</DependentUpon> <DependentUpon>Main.vb</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
@@ -150,6 +163,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="info.ico" /> <Content Include="info.ico" />
<None Include="Resources\Print20x20.png" />
<None Include="Resources\del.png" /> <None Include="Resources\del.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -16,9 +16,11 @@ Public Class cBenutzer
Property localdistinguishedName As String = "" Property localdistinguishedName As String = ""
Property suchname As String = "" Property suchname As String = ""
Property Hostname As String = "" Property Hostname As String = ""
Property Company As String = ""
Property Username As String = ""
'test
Function FillWithLoggedOnUser(Optional ByVal dcabfrage As Boolean = False, Optional ByVal LDAPa As String = "") '"LDAP://DC=VERAG,DC=OST,DC=DMN") Function FillWithLoggedOnUser(Optional ByVal dcabfrage As Boolean = False, Optional ByVal LDAPa As String = "") '"LDAP://DC=VERAG,DC=OST,DC=DMN")
@@ -30,9 +32,10 @@ Public Class cBenutzer
End Try End Try
Domäne = System.DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain.ToString Domäne = System.DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain.ToString
BenutzeranmeldeName = Environment.UserDomainName & "\" & Environment.UserName BenutzeranmeldeName = Environment.UserDomainName & "\" & Environment.UserName
Username = Environment.UserName
If dcabfrage = True Then If dcabfrage = True Then
'cRes.DebugText = userPrincipalName & LDAPa 'Class1.DebugText = userPrincipalName & LDAPa
FillFromDC(userPrincipalName, "userPrincipalName", LDAPa) FillFromDC(userPrincipalName, "userPrincipalName", LDAPa)
End If End If
End Function End Function
@@ -96,6 +99,7 @@ Public Class cBenutzer
.PropertiesToLoad.Add("distinguishedName") .PropertiesToLoad.Add("distinguishedName")
.PropertiesToLoad.Add("msDS-PrincipalName") .PropertiesToLoad.Add("msDS-PrincipalName")
.PropertiesToLoad.Add("userPrincipalName") .PropertiesToLoad.Add("userPrincipalName")
.PropertiesToLoad.Add("company")
End With End With
Dim Result As DirectoryServices.SearchResult = searcher.FindOne Dim Result As DirectoryServices.SearchResult = searcher.FindOne
@@ -110,6 +114,7 @@ Public Class cBenutzer
Me.BenutzeranmeldeName = blablabla(Result, "msDS-PrincipalName") Me.BenutzeranmeldeName = blablabla(Result, "msDS-PrincipalName")
Me.msDSPrincipalName = blablabla(Result, "msDS-PrincipalName") Me.msDSPrincipalName = blablabla(Result, "msDS-PrincipalName")
Me.userPrincipalName = blablabla(Result, "userPrincipalName") Me.userPrincipalName = blablabla(Result, "userPrincipalName")
Me.Company = blablabla(Result, "company")
Catch ex As Exception Catch ex As Exception
MsgBox("FillFromDC: " & ex.Message) MsgBox("FillFromDC: " & ex.Message)

258
cDomUser.vb Normal file
View File

@@ -0,0 +1,258 @@
Imports System.Reflection
Public Class cDomUser
Property du_ID As String = ""
Property du_Email_Activated As Boolean = False
Property du_EMail As String = ""
Property du_Vorname As String = ""
Property du_Nachname As String = ""
Property du_Abteilung As String = ""
Property du_TelNummer As String = ""
Property du_DW As String = ""
Property du_Kennwort As String = ""
Property du_Dom As String = ""
Property du_sAMAc As String = ""
Property du_Info As String = ""
Property du_autologoff As Boolean = False
Property du_autologofftime As DateTime
Property mit_username As String = ""
Property mit_pwd As String = ""
'-----------------------------------------
Dim SelectItems As String = ""
Public Exist As Boolean = False
Public Sub New()
SelectItems = Selectinator3000(getparameterlistMaster())
' MsgBox(SelectItems)
End Sub
Function getparameterlistMaster() As List(Of SQLVariable)
Dim list As New List(Of SQLVariable)
list.Add(New SQLVariable("du_ID", du_ID))
list.Add(New SQLVariable("du_Email_Activated", du_Email_Activated))
list.Add(New SQLVariable("du_EMail", du_EMail))
list.Add(New SQLVariable("du_Vorname", du_Vorname))
list.Add(New SQLVariable("du_Nachname", du_Nachname))
list.Add(New SQLVariable("du_Abteilung", du_Abteilung))
list.Add(New SQLVariable("du_TelNummer", du_TelNummer))
list.Add(New SQLVariable("du_DW", du_DW))
list.Add(New SQLVariable("du_Kennwort", du_Kennwort))
list.Add(New SQLVariable("du_Dom", du_Dom))
list.Add(New SQLVariable("du_sAMAc", du_sAMAc))
list.Add(New SQLVariable("du_Info", du_Info))
list.Add(New SQLVariable("du_autologoff", du_autologoff))
list.Add(New SQLVariable("du_autologofftime", du_autologofftime))
list.Add(New SQLVariable("mit_username", mit_username))
list.Add(New SQLVariable("mit_pwd", mit_pwd))
Return list
End Function
Public Function getDomUser(Filterspalte As String, Filterbegriff As String)
Dim ds As New DataSet
cSQL.SQL2DS("select " & SelectItems & " from [SQLGuide01.verag.ost.dmn].doku.dbo.tbl_domuser as Doku left join [SQLGuide01.verag.ost.dmn].ADMIN.dbo.tblMitarbeiter on mit_AliasAD_Username = du_sAMAc where " & Filterspalte & "= '" & Filterbegriff & "'", ds)
If ds.Tables(0).Rows.Count > 0 Then Exist = True
For Each c As DataColumn In ds.Tables(0).Columns
Dim propInfo As PropertyInfo = Me.GetType.GetProperty(c.ColumnName)
If propInfo IsNot Nothing Then
If Not IsDBNull(c.Table.Rows(0).Item(c)) Then
propInfo.SetValue(Me, c.Table.Rows(0).Item(c))
End If
End If
Next
' MsgBox("hier")
End Function
Public Function getDomUserByID(ID As String)
Dim ds As New DataSet
cSQL.SQL2DS("select " & SelectItems & " from [SQLGuide01.verag.ost.dmn].doku.dbo.tbl_domuser as Doku left join [SQLGuide01.verag.ost.dmn].ADMIN.dbo.tblMitarbeiter on mit_AliasAD_Username = du_sAMAc WHERE du_ID = '" & ID & "'", ds)
If ds.Tables(0).Rows.Count > 0 Then Exist = True
For Each c As DataColumn In ds.Tables(0).Columns
Dim propInfo As PropertyInfo = Me.GetType.GetProperty(c.ColumnName)
If propInfo IsNot Nothing Then
If Not IsDBNull(c.Table.Rows(0).Item(c)) Then
propInfo.SetValue(Me, c.Table.Rows(0).Item(c))
End If
End If
Next
' MsgBox("hier")
End Function
Public Function getDomUserByBenutzerAnmeldename(Dom As String, Username As String)
Dim ds As New DataSet
Try
cSQL.SQL2DS("select " & SelectItems & " from [SQLGuide01.verag.ost.dmn].doku.dbo.tbl_domuser as Doku left join [SQLGuide01.verag.ost.dmn].ADMIN.dbo.tblMitarbeiter on mit_AliasAD_Username = du_sAMAc WHERE du_Dom = '" & Dom & "' AND du_sAMAc = '" & Username & "'", ds)
If ds.Tables(0).Rows.Count > 0 Then Exist = True
If ds.Tables(0).Rows.Count = 0 Then Exit Function
'MsgBox("getDomUserByBenutzerAnmeldename" & Dom & vbCrLf & ds.Tables(0).Rows.Count & Username & vbCrLf)
For Each c As DataColumn In ds.Tables(0).Columns
Dim propInfo As PropertyInfo = Me.GetType.GetProperty(c.ColumnName)
If propInfo IsNot Nothing Then
If Not IsDBNull(c.Table.Rows(0).Item(c)) Then
propInfo.SetValue(Me, c.Table.Rows(0).Item(c))
End If
End If
Next
Catch ex As Exception
'MsgBox("getDomUserByBenutzerAnmeldename" & Dom & vbCrLf & ds.Tables(0).Rows.Count & Username & vbCrLf & ex.Message)
End Try
' MsgBox("hier")
End Function
Public Function Save()
If du_sAMAc = "" Or du_Dom = "" Then
MsgBox("Domänen-Benutzer und Domäne sind Pflichtfelder!") : Exit Function
End If
If CheckExist() = True Then
'-------------------------------------------------------------------------Update
Dim update, where As String
Dim list = getparameterlistMaster()
For Each i In list
If i.SQLText = "mit_pwd" Or i.SQLText = "mit_username" Then
ElseIf Not i.SQLText = "du_ID" Then
update &= "[" & i.SQLText & "]='" & i.SQLValue & "',"
Else
where &= "du_ID = '" & i.SQLValue & "'"
End If
Next
update = update.Substring(0, update.Length - 1)
cSQL.UpdateSQL("TbL_DomUser", update, where, Class1.DBDoku)
ElseIf CheckExist() = -1 Then
Exit Function
Else
'-------------------------------------------------------------------------Insert
Dim Spalten As String = ""
Dim Werte As String = ""
Dim InsertString As String = ""
du_ID = Guid.NewGuid().ToString("N")
Dim List As List(Of SQLVariable) = getparameterlistMaster()
For Each i In List
If i.SQLText = "mit_pwd" Or i.SQLText = "mit_username" Then
Else
Spalten &= i.SQLText & ","
Werte &= "'" & i.SQLValue & "',"
End If
Next
Spalten = Spalten.Substring(0, Spalten.Length - 1)
Werte = Werte.Substring(0, Werte.Length - 1)
cSQL.InsertSQL("TbL_DomUser", "(" & Spalten & ") VALUES (" & Werte & ")", Class1.DBDoku)
End If
End Function
Function CheckExist() As Boolean
Dim ds As New DataSet
cSQL.SQL2DS("select * from Doku.dbo.TbL_DomUser where du_ID = '" & du_ID & "'", ds, Class1.DBADMINBuchhaltung)
If ds.Tables(0).Rows.Count > 0 Then
Return True
Else
Dim dsa As New DataSet
cSQL.SQL2DS("select * from Doku.dbo.TbL_DomUser where du_sAMAc = '" & du_sAMAc & "' AND du_Dom = '" & du_Dom & "'", dsa, Class1.DBADMINBuchhaltung)
If dsa.Tables(0).Rows.Count > 0 Then
If MsgBox("Achtung! Die Kombination aus Domäne und Benutzer existiert bereits! Trotzdem speichern?", MsgBoxStyle.YesNo, "Speichern...") = MsgBoxResult.No Then
Return -1
Exit Function
End If
End If
Return False
End If
End Function
Public Function getFromAvisoUser(Optional ByVal AvisoUser As String = "")
If AvisoUser = "" Then
AvisoUser = Me.mit_username
End If
Dim ds As New DataSet
cSQL.SQL2DS("select * from ADMIN.dbo.tblMitarbeiter where mit_username = '" & AvisoUser & "'", ds, Class1.DBADMINBuchhaltung)
If ds.Tables(0).Rows.Count = 0 Then MsgBox("Benutzer nicht gefunden.") : Exit Function
If ds.Tables(0).Rows.Count = 1 Then
du_EMail = Class1.DBNull2emptyString(ds.Tables(0).Rows(0).Item("mit_email"))
If du_EMail.Length > 1 Then du_Email_Activated = True
mit_username = Class1.DBNull2emptyString(ds.Tables(0).Rows(0).Item("mit_username"))
mit_pwd = Class1.DBNull2emptyString(ds.Tables(0).Rows(0).Item("mit_pwd"))
du_Vorname = Class1.DBNull2emptyString(ds.Tables(0).Rows(0).Item("mit_vname"))
du_Nachname = Class1.DBNull2emptyString(ds.Tables(0).Rows(0).Item("mit_nname"))
du_Abteilung = Class1.DBNull2emptyString(ds.Tables(0).Rows(0).Item("mit_abteilung"))
du_TelNummer = Class1.DBNull2emptyString(ds.Tables(0).Rows(0).Item("mit_mobiltel"))
du_DW = Class1.DBNull2emptyString(ds.Tables(0).Rows(0).Item("mit_durchwahl"))
du_Dom = Class1.DBNull2emptyString(ds.Tables(0).Rows(0).Item("mit_aliasad_domain"))
du_sAMAc = Class1.DBNull2emptyString(ds.Tables(0).Rows(0).Item("mit_aliasad_username"))
End If
Exist = True
' MsgBox(du_EMail)
End Function
Public Function getFromAvisoUserLIST(AvisoUser As String)
Dim ds As New DataSet
Dim AvisoUserList As New List(Of cDomUser)
cSQL.SQL2DS("select * from ADMIN.dbo.tblMitarbeiter where mit_username = '" & AvisoUser & "'", ds, Class1.DBADMINBuchhaltung)
For Each row As DataRow In ds.Tables(0).Rows
Dim tempdu As New cDomUser
tempdu.du_EMail = Class1.DBNull2emptyString(row.Item("mit_email"))
If tempdu.du_EMail.Length > 1 Then tempdu.du_Email_Activated = True
tempdu.mit_username = Class1.DBNull2emptyString(row.Item("mit_username"))
tempdu.mit_pwd = Class1.DBNull2emptyString(row.Item("mit_pwd"))
tempdu.du_Vorname = Class1.DBNull2emptyString(row.Item("mit_vname"))
tempdu.du_Nachname = Class1.DBNull2emptyString(row.Item("mit_nname"))
tempdu.du_Abteilung = Class1.DBNull2emptyString(row.Item("mit_abteilung"))
tempdu.du_TelNummer = Class1.DBNull2emptyString(row.Item("mit_mobiltel"))
tempdu.du_DW = Class1.DBNull2emptyString(row.Item("mit_durchwahl"))
tempdu.du_Dom = Class1.DBNull2emptyString(row.Item("mit_aliasad_domain"))
tempdu.du_sAMAc = Class1.DBNull2emptyString(row.Item("mit_aliasad_username"))
AvisoUserList.Add(tempdu)
Next
Return AvisoUserList
End Function
Public Function Selectinator3000(varlist As List(Of SQLVariable)) As String
Dim Ding As String = ""
For Each var In varlist
Ding &= var.SQLText & ", "
Next
Ding = Ding.Substring(0, (Ding.Length - 2))
Return Ding
End Function
Public Function Delete()
If MsgBox("Benutzer " & du_Vorname & " " & du_Nachname & ", " & du_sAMAc & " löschen?", MsgBoxStyle.OkCancel, "Benutzer löschen?") = MsgBoxResult.Ok Then
cSQL.DeleteSQL("Doku.dbo.TbL_DomUser", "du_ID = '" & du_ID & "'", Class1.DBADMINBuchhaltung)
Else
Exit Function
End If
End Function
Public Shared Function Delete(ID As String)
If MsgBox("Benutzer löschen?", MsgBoxStyle.OkCancel, "Benutzer löschen?") = MsgBoxResult.Ok Then
cSQL.DeleteSQL("Doku.dbo.TbL_DomUser", "du_ID = '" & ID & "'", Class1.DBADMINBuchhaltung)
Else
Exit Function
End If
End Function
End Class

View File

@@ -1,8 +1,12 @@
Public Class cRes Public Class cRes
Public Shared DBConString As String = "Server=buchhaltung.verag.ost.dmn\SQLEXPRESS;Initial Catalog=Doku;User ID=sa;Password=BmWr501956;Connection Timeout=5;" Public Shared DBConString As String = "Server=sqlcluster.verag.ost.dmn\verag;Initial Catalog=Doku;User ID=sa;Password=BmWr501956;Connection Timeout=5;"
'Public Shared DBConString As String = "Server=buchhaltung.verag.ost.dmn\SQLEXPRESS;Initial Catalog=Doku;User ID=sa;Password=BmWr501956;Connection Timeout=5;"
Public Shared DBConstringDev As String = "Server=DEVELOPER.verag.ost.dmn\DEVSQL;Initial Catalog=Doku;User ID=sa;Password=BmWr501956;Connection Timeout=5;" Public Shared DBConstringDev As String = "Server=DEVELOPER.verag.ost.dmn\DEVSQL;Initial Catalog=Doku;User ID=sa;Password=BmWr501956;Connection Timeout=5;"
Public Shared LocalUser As New cBenutzer Public Shared LocalUser As New cBenutzer
Public Shared LocalTeamviewerID As String Public Shared LocalTeamviewerID As String
Public Shared LocalDomUser As New cDomUser
Public Shared DisableAutoLogoff As Boolean = False
End Class End Class

51
cSQL.vb
View File

@@ -1,22 +1,28 @@
Imports System.Data.SqlClient Imports System.Data.SqlClient
Public Class cSQL Public Class cSQL
Public Shared Sub SQL2DS(ByRef selector As String, ByRef ds As DataSet)
Public Shared Sub SQL2DS(ByRef selector As String, ByRef ds As DataSet, Optional ByRef DBConnect As String = "")
If DBConnect = "" Then DBConnect = Class1.DBConString
Dim con As New SqlConnection Dim con As New SqlConnection
Dim cmd As New SqlCommand Dim cmd As New SqlCommand
con.ConnectionString = cRes.DBConString con.ConnectionString = DBConnect 'Class1.DBConString
cmd.Connection = con cmd.Connection = con
Try
Dim dataadapter As New SqlDataAdapter(selector, con) Dim dataadapter As New SqlDataAdapter(selector, con)
con.Open() con.Open()
dataadapter.Fill(ds) dataadapter.Fill(ds)
con.Close() con.Close()
Catch ex As Exception
'MsgBox("hier")
End Try
End Sub End Sub
Public Shared Sub UpdateSQL(ByRef table As String, ByRef values As String, ByRef where As String) Public Shared Sub UpdateSQL(ByRef table As String, ByRef values As String, ByRef where As String, Optional ByRef DBConnect As String = "")
If DBConnect = "" Then DBConnect = Class1.DBConString
Dim con As New SqlConnection Dim con As New SqlConnection
Dim cmd As New SqlCommand Dim cmd As New SqlCommand
con.ConnectionString = cRes.DBConString con.ConnectionString = DBConnect ' Class1.DBConString
cmd.Connection = con cmd.Connection = con
con.Open() con.Open()
@@ -25,10 +31,11 @@ Public Class cSQL
con.Close() con.Close()
End Sub End Sub
Public Shared Sub InsertSQL(ByRef table As String, ByRef insert As String) Public Shared Sub InsertSQL(ByRef table As String, ByRef insert As String, Optional ByRef DBConnect As String = "")
If DBConnect = "" Then DBConnect = Class1.DBConString
Dim con As New SqlConnection Dim con As New SqlConnection
Dim cmd As New SqlCommand Dim cmd As New SqlCommand
con.ConnectionString = cRes.DBConString con.ConnectionString = DBConnect ' Class1.DBConString
cmd.Connection = con cmd.Connection = con
con.Open() con.Open()
@@ -37,10 +44,11 @@ Public Class cSQL
con.Close() con.Close()
End Sub End Sub
Public Shared Sub DeleteSQL(ByRef table As String, ByRef where As String) Public Shared Sub DeleteSQL(ByRef table As String, ByRef where As String, Optional ByRef DBConnect As String = "")
If DBConnect = "" Then DBConnect = Class1.DBConString
Dim con As New SqlConnection Dim con As New SqlConnection
Dim cmd As New SqlCommand Dim cmd As New SqlCommand
con.ConnectionString = cRes.DBConString con.ConnectionString = DBConnect ' Class1.DBConString
cmd.Connection = con cmd.Connection = con
con.Open() con.Open()
@@ -49,6 +57,19 @@ Public Class cSQL
con.Close() con.Close()
End Sub End Sub
Public Shared Sub SQLCommand(command As String, Optional ByRef DBConnect As String = "")
If DBConnect = "" Then DBConnect = Class1.DBConString
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = DBConnect ' Class1.DBConString
cmd.Connection = con
con.Open()
cmd.CommandText = command
cmd.ExecuteNonQuery()
con.Close()
End Sub
End Class End Class
@@ -70,7 +91,9 @@ Public Class SQLVariable
Public ReadOnly Property SQLValue() As Object Public ReadOnly Property SQLValue() As Object
Get Get
Return Value Return value
End Get End Get
End Property End Property
End Class End Class

87
frmLogOff.Designer.vb generated Normal file
View File

@@ -0,0 +1,87 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmLogOff
Inherits System.Windows.Forms.Form
'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Wird vom Windows Form-Designer benötigt.
Private components As System.ComponentModel.IContainer
'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich.
'Das Bearbeiten ist mit dem Windows Form-Designer möglich.
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.Label1 = New System.Windows.Forms.Label()
Me.BtnAbbrechen = New System.Windows.Forms.Button()
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.Label2 = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 20.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(12, 9)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(703, 62)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Automatische Abmeldung wird in Kürze durchgeführt." & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "Nicht gespeicherte Dokumente " &
"werden verworfen."
'
'BtnAbbrechen
'
Me.BtnAbbrechen.Font = New System.Drawing.Font("Microsoft Sans Serif", 22.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.BtnAbbrechen.ForeColor = System.Drawing.Color.Red
Me.BtnAbbrechen.Location = New System.Drawing.Point(188, 200)
Me.BtnAbbrechen.Name = "BtnAbbrechen"
Me.BtnAbbrechen.Size = New System.Drawing.Size(368, 53)
Me.BtnAbbrechen.TabIndex = 1
Me.BtnAbbrechen.Text = "Abbrechen"
Me.BtnAbbrechen.UseVisualStyleBackColor = True
'
'Timer1
'
Me.Timer1.Interval = 1000
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 20.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(322, 112)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(95, 31)
Me.Label2.TabIndex = 2
Me.Label2.Text = "Label2"
'
'frmLogOff
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(720, 292)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.BtnAbbrechen)
Me.Controls.Add(Me.Label1)
Me.Name = "frmLogOff"
Me.Text = "Abmeldung"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents Label1 As Label
Friend WithEvents BtnAbbrechen As Button
Friend WithEvents Timer1 As Timer
Friend WithEvents Label2 As Label
End Class

123
frmLogOff.resx Normal file
View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="Timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

28
frmLogOff.vb Normal file
View File

@@ -0,0 +1,28 @@
Public Class frmLogOff
Dim FinalCountdown As Integer = 30
Private Sub frmLogOff_Load(sender As Object, e As EventArgs) Handles Me.Load
Label2.Text = FinalCountdown.ToString
Timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If FinalCountdown > 0 Then
FinalCountdown = FinalCountdown - 1
Label2.Text = FinalCountdown.ToString
Else
Timer1.Stop()
Process.Start("shutdown", "-l")
Me.Close()
End If
End Sub
Private Sub BtnAbbrechen_Click(sender As Object, e As EventArgs) Handles BtnAbbrechen.Click
Timer1.Stop()
cRes.DisableAutoLogoff = True
Me.Close()
End Sub
End Class