Report Lokale TeamviewerID

This commit is contained in:
ms
2019-12-02 15:57:04 +01:00
parent 6cdb9c14a1
commit f704d3b440
16 changed files with 2177 additions and 40 deletions

BIN
TSAnmeldung/Admin.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@@ -1,5 +1,5 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Partial Class Main
Inherits System.Windows.Forms.Form
'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
@@ -22,10 +22,98 @@ Partial Class Form1
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
Me.components = New System.ComponentModel.Container()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Main))
Me.btnLogOFF = New System.Windows.Forms.Button()
Me.btnResetSession = New System.Windows.Forms.Button()
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.btnShutdown = New System.Windows.Forms.Button()
Me.cboxStandort = New System.Windows.Forms.ComboBox()
Me.Timer2 = New System.Windows.Forms.Timer(Me.components)
Me.SuspendLayout()
'
'btnLogOFF
'
Me.btnLogOFF.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnLogOFF.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnLogOFF.Image = Global.TSAnmeldung.My.Resources.Resources.LogOff20
Me.btnLogOFF.ImageAlign = System.Drawing.ContentAlignment.MiddleRight
Me.btnLogOFF.Location = New System.Drawing.Point(12, 46)
Me.btnLogOFF.Name = "btnLogOFF"
Me.btnLogOFF.Size = New System.Drawing.Size(184, 28)
Me.btnLogOFF.TabIndex = 28
Me.btnLogOFF.Text = "Abmelden"
Me.btnLogOFF.UseVisualStyleBackColor = True
'
'btnResetSession
'
Me.btnResetSession.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnResetSession.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnResetSession.Image = Global.TSAnmeldung.My.Resources.Resources.Reload20
Me.btnResetSession.ImageAlign = System.Drawing.ContentAlignment.MiddleRight
Me.btnResetSession.Location = New System.Drawing.Point(12, 12)
Me.btnResetSession.Name = "btnResetSession"
Me.btnResetSession.Size = New System.Drawing.Size(184, 28)
Me.btnResetSession.TabIndex = 29
Me.btnResetSession.Text = "Sitzung neu starten"
Me.btnResetSession.UseVisualStyleBackColor = True
'
'Timer1
'
Me.Timer1.Interval = 15
'
'btnShutdown
'
Me.btnShutdown.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnShutdown.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnShutdown.Image = Global.TSAnmeldung.My.Resources.Resources.ShutDown20
Me.btnShutdown.ImageAlign = System.Drawing.ContentAlignment.MiddleRight
Me.btnShutdown.Location = New System.Drawing.Point(12, 114)
Me.btnShutdown.Name = "btnShutdown"
Me.btnShutdown.Size = New System.Drawing.Size(184, 28)
Me.btnShutdown.TabIndex = 31
Me.btnShutdown.Text = "Ausschalten"
Me.btnShutdown.UseVisualStyleBackColor = True
'
'cboxStandort
'
Me.cboxStandort.FormattingEnabled = True
Me.cboxStandort.Items.AddRange(New Object() {"VERAG SUB (rdpintern.verag.ag)", "VERAG SBG (terminalsbg.verag.ag)", "BACKUP", "Personalisiert"})
Me.cboxStandort.Location = New System.Drawing.Point(12, 80)
Me.cboxStandort.Name = "cboxStandort"
Me.cboxStandort.Size = New System.Drawing.Size(183, 21)
Me.cboxStandort.TabIndex = 32
'
'Timer2
'
Me.Timer2.Interval = 5000
'
'Main
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(800, 450)
Me.Text = "Form1"
Me.BackColor = System.Drawing.SystemColors.ControlLightLight
Me.ClientSize = New System.Drawing.Size(208, 156)
Me.ControlBox = False
Me.Controls.Add(Me.cboxStandort)
Me.Controls.Add(Me.btnShutdown)
Me.Controls.Add(Me.btnResetSession)
Me.Controls.Add(Me.btnLogOFF)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximumSize = New System.Drawing.Size(224, 195)
Me.MinimizeBox = False
Me.MinimumSize = New System.Drawing.Size(224, 195)
Me.Name = "Main"
Me.ShowIcon = False
Me.Text = "TSAnmeldung"
Me.ResumeLayout(False)
End Sub
Friend WithEvents btnLogOFF As Button
Friend WithEvents btnResetSession As Button
Friend WithEvents Timer1 As Timer
Friend WithEvents btnShutdown As Button
Friend WithEvents cboxStandort As ComboBox
Friend WithEvents Timer2 As Timer
End Class

1259
TSAnmeldung/Form1.resx Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,289 @@
Public Class Form1
Imports System
Imports System.Diagnostics
Imports System.Threading
Imports System.Diagnostics.Eventing.Reader
Public Class Main
Public WithEvents mstsc As New Process
Public sAppPath As String = Application.StartupPath
Public LDAP As String
Public autoconnect, autologoff As Boolean
Public debug As Boolean = False
Public ConBroker As String
Public ConString As String
Public ConType As String
Dim lastupdate As DateTime
Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Text = "TSAnmeldung " & My.Resources.ProgVersion
SendEvents()
WoBinIch()
mstsc.EnableRaisingEvents = True
Try
Dim GroupList As List(Of String) = cRes.GetUserGroupMembership(Environment.UserName, LDAP)
For Each group As String In GroupList
If group = "CN=SG_DEBUG" Then
debug = True
Timer2.Enabled = True
End If
Next
Catch ex As Exception
End Try
Dim i As Integer
For Each s As String In Environment.GetCommandLineArgs
If i > 0 Then
If s = "/d" Or s = "-d" Then
autoconnect = False
autologoff = False
Else
autoconnect = True
End If
End If
i += 1
Next
' MsgBox(autoconnect)
Timer1.Enabled = autoconnect
cRes.LocalUser.FillWithLoggedOnUser()
cRes.LocalTeamviewerID = getTeamViewerID()
Report()
End Sub
Function Report()
lastupdate = Date.Now
Dim ds As New DataSet
cSQL.SQL2DS("select * from TbL_ThinClients where Benutzeranmeldename = '" & cRes.LocalUser.BenutzeranmeldeName & " ' ", ds)
If Not ds.Tables(0).Rows.Count = 0 Then
RemoveSitzung()
End If
cSQL.InsertSQL("TbL_ThinClients", "(Benutzeranmeldename, Name, TeamviewerID, LastReport, ClientName) VALUES (
'" & cRes.LocalUser.BenutzeranmeldeName & "',
'" & cRes.LocalUser.Name & "',
'" & cRes.LocalTeamviewerID & "',
'" & Date.Now & "',
'" & cRes.LocalUser.Hostname & "')")
End Function
Sub RemoveSitzung()
cSQL.DeleteSQL("TbL_ThinClients", "Benutzeranmeldename = '" & cRes.LocalUser.BenutzeranmeldeName & " ' ")
End Sub
Public Sub WoBinIch()
If Environment.UserDomainName = "VERAGOST" Then
cboxStandort.SelectedItem = "VERAG SUB (rdpintern.verag.ag)"
LDAP = "LDAP://DC=VERAG,DC=OST,DC=DMN"
autoconnect = True
autologoff = True
ElseIf Environment.UserDomainName = "VERAG-SBG" Then
cboxStandort.SelectedItem = "VERAG SBG (terminalsbg.verag.ag)"
LDAP = "LDAP://DC=VERAG-SBG,DC=LOCAL"
autoconnect = True
autologoff = True
Else
autoconnect = False
autologoff = False
End If
If sAppPath Like "*\bin\Debug" Or Environment.UserName = "miesenbeck" Or Environment.UserName = "Administrator" Or autologoff = False Then
autoconnect = False
Me.ControlBox = True
End If
If Not LoadParameters(Environment.UserName, ConType, ConString) = False Then
cboxStandort.SelectedItem = "Personalisiert"
'ConString = LoadParameters(Environment.UserName)
End If
'Select Case Environment.UserName
' Case "miesenbeck"
' cboxStandort.SelectedItem = "Personalisiert"
' Case "bluxbauer"
' cboxStandort.SelectedItem = "Personalisiert"
'End Select
End Sub
Public Function rdp(host As String, Optional ByVal options As String = "", Optional ByVal rdpfile As String = "")
'Dim mstsc As New Process()
' mstsc.EnableRaisingEvents = True
If rdpfile = "" Then
mstsc.StartInfo.FileName = "mstsc.exe"
mstsc.StartInfo.UseShellExecute = False
mstsc.StartInfo.Arguments = " /v: " & host & " " & options
mstsc.Start()
Else
mstsc.StartInfo.FileName = "mstsc.exe"
mstsc.StartInfo.UseShellExecute = False
mstsc.StartInfo.Arguments = " \\verag.ost.dmn\NETLOGON\RDPs\" & rdpfile
mstsc.Start()
End If
Do
If Process.GetProcessesByName("mstsc").Length > 0 Then
Thread.Sleep(500)
Else
LogOff()
'Process.Start("shutdown", "-l")
'MsgBox("LogOff")
Exit Function
End If
Application.DoEvents()
Loop
End Function
Public Function killpro(processname As String)
For Each p As Process In Process.GetProcessesByName(processname)
p.Kill()
Next
End Function
Private Sub btnResetSession_Click(sender As Object, e As EventArgs) Handles btnResetSession.Click
killpro("mstsc")
'rdp("rdpintern.verag.ag", "/noConsentPrompt /multimon /control")
connect()
End Sub
Private Sub connect()
Select Case cboxStandort.SelectedItem
Case "Personalisiert"
If ConType = "rdp" Then
rdp(-1, -1, ReturnTerminalserver())
Else
rdp(ConString, "/multimon")
End If
Case Else
If cRes.CheckTermServer(ReturnTerminalserver()) Then
rdp(ReturnTerminalserver(), "/multimon")
Else
autologoff = False
autoconnect = False
MsgBox("Verbindung konnte nicht aufgebaut werden (Server ist nicht erreichbar)")
End If
End Select
End Sub
Private Sub btnLogOFF_Click(sender As Object, e As EventArgs) Handles btnLogOFF.Click
System.Diagnostics.Process.Start("shutdown", "-l")
End Sub
Public Sub SendEvents()
Dim query As New EventLogQuery("System", PathType.LogName)
Dim watcher As New EventLogWatcher(query)
AddHandler watcher.EventRecordWritten, AddressOf watcher_EventRecordWritten
watcher.Enabled = True
Console.ReadLine()
End Sub
Public Sub watcher_EventRecordWritten(sender As Object, e As EventRecordWrittenEventArgs)
'Console.WriteLine(e.EventRecord.ToXml())
If e.EventRecord.ProviderName = "uwfvol" Then
' MsgBox("EventID: " & e.EventRecord.Id & vbCrLf & "Info: " & e.EventRecord.Properties(0).Value)
If debug Then cRes.sendmsg("192.168.0.121", "EventID " & e.EventRecord.Id & "bei Benutzer " & Environment.UserName & " auf Rechner: " & Environment.MachineName & ", Uptime: " & cRes.getuptime())
If e.EventRecord.Id = 2 Then
MsgBox("Speicherauslastung am ThinClient ist kritisch und daher sollte dieser ehestmöglich neu gestartet werden!" & vbCrLf & "Wenn diese Meldung ÖFTER auftritt, bitte bei Sebastian (DW 861) Bescheid geben.", MsgBoxStyle.Critical, "Kritische Speicherauslastung")
cRes.bringtofocus("mstsc.exe")
End If
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Timer1.Enabled = False
'MsgBox("Tick")
connect()
End Sub
Private Sub btnShutdown_Click(sender As Object, e As EventArgs) Handles btnShutdown.Click
If MsgBox("ThinClient ausschalten?", MsgBoxStyle.OkCancel) = MsgBoxResult.Ok Then
System.Diagnostics.Process.Start("shutdown", "-s -t 0")
End If
End Sub
Private Sub Main_Closed(sender As Object, e As EventArgs) Handles Me.Closed
LogOff()
End Sub
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
cRes.Log2NAS("meh", "\\192.168.0.253\backup\temp_Sebastian\Logs\" & Environment.UserName & ".txt")
End Sub
Public Sub LogOff()
RemoveSitzung()
If sAppPath Like "*\bin\Debug" Or Environment.UserName = "miesenbeck" Or Environment.UserName = "Administrator" Or autologoff = False Then
Me.ControlBox = True
Else
System.Diagnostics.Process.Start("shutdown", "-l")
End If
End Sub
Public Function ReturnTerminalserver()
If cboxStandort.SelectedItem = "VERAG SUB (rdpintern.verag.ag)" Then Return "rdpintern.verag.ag"
If cboxStandort.SelectedItem = "VERAG SBG (terminalsbg.verag.ag)" Then Return "terminalsbg.verag.ag"
If cboxStandort.SelectedItem = "BACKUP" Then
If cRes.CheckTermServer("192.168.0.235") Then Return "192.168.0.235" : Exit Function
If cRes.CheckTermServer("192.168.0.101") Then Return "192.168.0.101" : Exit Function
If cRes.CheckTermServer("192.168.0.92") Then Return "192.168.0.92" : Exit Function
End If
If cboxStandort.SelectedItem = "Personalisiert" Then
Return ConString
End If
End Function
Public Function LoadParameters(ByVal Benutzername As String, ByRef _ConType As String, ByRef _ConString As String)
Try
Dim lines = IO.File.ReadAllLines(sAppPath & "\TSAnmeldung.ini")
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
_ConType = objFields(1).ToString
_ConString = objFields(2).ToString
Return True
Exit Function
End Select
Next
Return False
Catch ex As Exception
' MsgBox("Fehler beim Lesen TSAnmeldung.ini: " & vbCrLf & ex.Message)
End Try
End Function
Function getTeamViewerID()
Dim Reg As String = Nothing
If My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\TeamViewer", "ClientIDOfTSUser", Nothing) Is Nothing Then
Reg = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\TeamViewer", "ClientID", Nothing)
Else
Reg = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\TeamViewer", "ClientIDOfTSUser", Nothing)
End If
Return Reg
End Function
End Class

View File

@@ -32,7 +32,7 @@ Namespace My
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.TSAnmeldung.Form1
Me.MainForm = Global.TSAnmeldung.Main
End Sub
End Class
End Namespace

View File

@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyVersion("1.0.0.4")>
<Assembly: AssemblyFileVersion("1.0.0.0")>

View File

@@ -1,41 +1,42 @@
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.42000
' Dieser Code wurde von einem Tool generiert.
' Laufzeitversion:4.0.30319.42000
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
' der Code erneut generiert wird.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Imports System
Namespace My.Resources
'This class was auto-generated by the StronglyTypedResourceBuilder
'class via a tool like ResGen or Visual Studio.
'To add or remove a member, edit your .ResX file then rerun ResGen
'with the /str option, or rebuild your VS project.
'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
'-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
'''<summary>
''' A strongly-typed resource class, for looking up localized strings, etc.
''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
Friend Module Resources
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
Public Module Resources
Private resourceMan As Global.System.Resources.ResourceManager
Private resourceCulture As Global.System.Globalization.CultureInfo
'''<summary>
''' Returns the cached ResourceManager instance used by this class.
''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Public ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get
If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("TSAnmeldung.Resources", GetType(Resources).Assembly)
@@ -44,19 +45,58 @@ Namespace My.Resources
Return resourceMan
End Get
End Property
'''<summary>
''' Overrides the current thread's CurrentUICulture property for all
''' resource lookups using this strongly typed resource class.
''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend Property Culture() As Global.System.Globalization.CultureInfo
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Public Property Culture() As Global.System.Globalization.CultureInfo
Get
Return resourceCulture
End Get
Set(ByVal value As Global.System.Globalization.CultureInfo)
Set
resourceCulture = value
End Set
End Property
'''<summary>
''' Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
'''</summary>
Public ReadOnly Property LogOff20() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("LogOff20", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
'''<summary>
''' Sucht eine lokalisierte Zeichenfolge, die 1.0.1.0 ähnelt.
'''</summary>
Public ReadOnly Property ProgVersion() As String
Get
Return ResourceManager.GetString("ProgVersion", resourceCulture)
End Get
End Property
'''<summary>
''' Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
'''</summary>
Public ReadOnly Property Reload20() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("Reload20", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
'''<summary>
''' Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
'''</summary>
Public ReadOnly Property ShutDown20() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("ShutDown20", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
End Module
End Namespace

View File

@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
: 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">
@@ -68,9 +69,10 @@
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<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">
@@ -85,9 +87,10 @@
<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" msdata:Ordinal="1" />
<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">
@@ -109,9 +112,22 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="LogOff20" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\LogOff20.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="ProgVersion" xml:space="preserve">
<value>1.0.1.0</value>
</data>
<data name="Reload20" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Reload20.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="ShutDown20" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ShutDown20.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -14,6 +14,21 @@
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -47,10 +62,16 @@
<PropertyGroup>
<OptionInfer>On</OptionInfer>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Admin.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.DirectoryServices" />
<Reference Include="System.DirectoryServices.AccountManagement" />
<Reference Include="System.DirectoryServices.Protocols" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
@@ -73,6 +94,9 @@
<Import Include="System.Threading.Tasks" />
</ItemGroup>
<ItemGroup>
<Compile Include="cBenutzer.vb" />
<Compile Include="cRes.vb" />
<Compile Include="cSQL.vb" />
<Compile Include="Form1.vb">
<SubType>Form</SubType>
</Compile>
@@ -97,8 +121,11 @@
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<Generator>PublicVbMyResourcesResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
<CustomToolNamespace>My.Resources</CustomToolNamespace>
<SubType>Designer</SubType>
@@ -116,5 +143,32 @@
</None>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\LogOff20.bmp" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Reload20.bmp" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\ShutDown20.bmp" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Image1.bmp" />
</ItemGroup>
<ItemGroup>
<Content Include="Admin.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6.1 %28x86 und x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
</Project>

173
TSAnmeldung/cBenutzer.vb Normal file
View File

@@ -0,0 +1,173 @@
Imports System.Reflection
Public Class cBenutzer
Property Name As String = ""
Property userPrincipalName As String = ""
Property Domäne As String = ""
Property BenutzeranmeldeName As String = ""
Property Nachname As String = ""
Property Vorname As String = ""
Property Mail As String = ""
Property distinguishedName As String = ""
Property cn As String = ""
Property msDSPrincipalName As String = ""
Property localdistinguishedName As String = ""
Property suchname As String = ""
Property Hostname As String = ""
Function FillWithLoggedOnUser(Optional ByVal dcabfrage As Boolean = False, Optional ByVal LDAPa As String = "") '"LDAP://DC=VERAG,DC=OST,DC=DMN")
Try
userPrincipalName = System.DirectoryServices.AccountManagement.UserPrincipal.Current.UserPrincipalName
Name = System.DirectoryServices.AccountManagement.UserPrincipal.Current.Name
Hostname = Environment.MachineName
Catch
End Try
Domäne = System.DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain.ToString
BenutzeranmeldeName = Environment.UserDomainName & "\" & Environment.UserName
If dcabfrage = True Then
'cRes.DebugText = userPrincipalName & LDAPa
FillFromDC(userPrincipalName, "userPrincipalName", LDAPa)
End If
End Function
Function FillFromDC(ByVal searchname As String, Optional ByVal searchfilter As String = "distinguishedName", Optional ByVal LDAP As String = "LDAP://DC=VERAG,DC=OST,DC=DMN")
Try
localdistinguishedName = searchname
suchname = searchname
If searchname.Contains("ForeignSecurityPrincipals") Then
'MsgBox("!")
Dim FSlocDirectoryEntry As New DirectoryServices.DirectoryEntry(LDAP)
Dim FSsearcher As New DirectoryServices.DirectorySearcher
With FSsearcher
.SearchRoot = FSlocDirectoryEntry
.Filter = searchfilter & "=" & searchname
.PropertiesToLoad.Add("msDS-PrincipalName")
End With
Dim FSResult As DirectoryServices.SearchResult = FSsearcher.FindOne
' MsgBox(FSResult.Properties("msDS-PrincipalName").Count)
searchname = FSResult.Properties("msDS-PrincipalName").Item(0)
Dim DomainName As String = searchname.Substring(0, searchname.IndexOf("\"))
' MsgBox(DomainName)
Select Case DomainName
Case "IMEX"
Me.Domäne = "imex.local"
LDAP = "LDAP://DC=IMEX,DC=LOCAL"
'MsgBox("Me.Domäne = imex.local")
Case "VERAGNEUHAUS"
Me.Domäne = "VERAGNEUHAUS.local"
LDAP = "LDAP://DC=VERAGNEUHAUS,DC=LOCAL"
Case "VERAGOST"
Me.Domäne = "verag.ost.dmn"
End Select
' MsgBox(searchname)
searchname = searchname.Substring((searchname.IndexOf("\") + 1), searchname.Length - searchname.IndexOf("\") - 1)
searchfilter = "sAMAccountName"
Else
'Me.Domäne = "verag.ost.dmn"
End If
If LDAP = "LDAP://DC=VERAG,DC=OST,DC=DMN" Then Me.Domäne = "verag.ost.dmn"
' MsgBox(searchname & vbCrLf & searchfilter & vbCrLf & Me.Domäne & vbCrLf & LDAP)
Dim locDirectoryEntry As New DirectoryServices.DirectoryEntry(LDAP)
' Dim Searcher1 As New DirectoryServices.DirectorySearcher(locDirectoryEntry, searchfilter & "=" & searchname)
Dim searcher As New DirectoryServices.DirectorySearcher
With searcher
.SearchRoot = locDirectoryEntry
.Filter = searchfilter & "=" & searchname
' .ExtendedDN = True
.PropertiesToLoad.Add("sn")
.PropertiesToLoad.Add("givenName")
.PropertiesToLoad.Add("mail")
.PropertiesToLoad.Add("distinguishedName")
.PropertiesToLoad.Add("cn")
.PropertiesToLoad.Add("distinguishedName")
.PropertiesToLoad.Add("msDS-PrincipalName")
.PropertiesToLoad.Add("userPrincipalName")
End With
Dim Result As DirectoryServices.SearchResult = searcher.FindOne
Me.Nachname = blablabla(Result, "sn")
Me.Vorname = blablabla(Result, "givenName")
Me.Mail = blablabla(Result, "mail")
Me.distinguishedName = blablabla(Result, "distinguishedName")
Me.cn = blablabla(Result, "cn")
Me.Name = blablabla(Result, "cn")
Me.BenutzeranmeldeName = blablabla(Result, "msDS-PrincipalName")
Me.msDSPrincipalName = blablabla(Result, "msDS-PrincipalName")
Me.userPrincipalName = blablabla(Result, "userPrincipalName")
Catch ex As Exception
MsgBox("FillFromDC: " & ex.Message)
End Try
End Function
Function isDokuAdmin() As Boolean
Dim ds As New DataSet
cSQL.SQL2DS("select * from TbL_Berechtigungen where Benutzeranmeldename = '" & Me.BenutzeranmeldeName & "' AND Standort = 'DokuAdmin'", ds)
If ds.Tables(0).Rows.Count > 0 Then
Return True
Else
Return False
End If
End Function
Function blablabla(result As DirectoryServices.SearchResult, Prop As String) As String
If result.Properties(Prop).Count = 0 Then
Return ""
Else
Return result.Properties(Prop)(0)
End If
End Function
Function emptyreturn(ByVal ding As String)
If ding Is Nothing Then
Return ""
Else
Return ding
End If
End Function
End Class
Public Class cBenutzergruppe
Public Shared Function GetUsersInGroup(ByVal groupname As String, Optional ByVal LDAP As String = "LDAP://DC=VERAG,DC=OST,DC=DMN") As List(Of String)
Dim Userlist As New List(Of String)
Dim locDirectoryEntry As New DirectoryServices.DirectoryEntry(LDAP)
Dim Searcher As New DirectoryServices.DirectorySearcher(locDirectoryEntry, "sAMAccountName=" & groupname)
Dim Result As DirectoryServices.SearchResult = Searcher.FindOne
If Result IsNot Nothing Then
For Each User In Result.Properties("Member")
Userlist.Add(User)
Next
End If
Return Userlist
End Function
End Class
Public Class cSharedClasses
' Public Shared LoggedOnUser As New cBenutzer
End Class

145
TSAnmeldung/cRes.vb Normal file
View File

@@ -0,0 +1,145 @@
Imports System.IO
Imports System.Net.Sockets
Imports System.Diagnostics.Process
Public Class cRes
Public Shared LocalUser As New cBenutzer
Public Shared LocalTeamviewerID As String
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 Function GetUserGroupMembership(ByVal locUsername As String, ByVal LDAP As String) As List(Of String)
Dim locResult As New List(Of String)
Try
Dim locDirectoryEntry As New DirectoryServices.DirectoryEntry(LDAP) ' ActiveDirectory-Pfad anpassen
Dim locDirectorySearcher As New DirectoryServices.DirectorySearcher(locDirectoryEntry, "sAMAccountName=" & locUsername)
Dim locSearchResult As DirectoryServices.SearchResult = locDirectorySearcher.FindOne
If locSearchResult IsNot Nothing Then
Dim locUserEntry As New DirectoryServices.DirectoryEntry(locSearchResult.Path)
Dim locGroups As Object = locUserEntry.Invoke("Groups")
For Each locGroupObj As Object In DirectCast(locGroups, IEnumerable)
Dim locGroupEntry As New DirectoryServices.DirectoryEntry(locGroupObj)
locResult.Add(locGroupEntry.Name)
Next
Else
Debug.WriteLine("User nicht gefunden!")
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "GetUserGroupMembership", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Return locResult
End Function
Public Shared Function Log2NAS(abfrage As String, speicherort As String)
Try
Using sw As StreamWriter = File.AppendText(speicherort)
'Using sw As StreamWriter = New System.IO.StreamWriter(speicherort)
Dim oProcess As New Process()
'Dim oStartInfo As New ProcessStartInfo("uwfmgr overlay get-availablespace")
Dim oStartInfo As New ProcessStartInfo("powershell.exe", "-command uwfmgr overlay get-availablespace")
'Dim oStartInfo As New ProcessStartInfo("cmd.exe", "/c ping 192.168.0.190 -n 1 > C:\temp.txt")
oStartInfo.Domain = "veragost"
oStartInfo.UserName = "administrator"
oStartInfo.PasswordInClearText = "BmWr501956"
oStartInfo.CreateNoWindow = True
oStartInfo.UseShellExecute = False
oStartInfo.RedirectStandardOutput = True
oStartInfo.StandardOutputEncoding = System.Text.Encoding.GetEncoding(437)
oProcess.StartInfo = oStartInfo
Try
oProcess.Start()
Dim sOutput As String
Using oStreamReader As System.IO.StreamReader = oProcess.StandardOutput
sOutput = Date.Now & "-UpTime: " & cRes.getuptime() & " - " & Convert.ToString(oStreamReader.ReadToEnd())
'Dim sOutputLine As List(Of String) = File.ReadLines("C:\temp.txt").ToList
'sOutput = Date.Now & " : " & sOutputLine(sOutputLine.Count - 1).ToString()
End Using
sw.WriteLine(sOutput)
sw.Close()
Catch meh As Exception
sw.WriteLine(Date.Now & ": Fehler beim Ausfuehren des Prozesses: " & meh.Message)
sw.Close()
End Try
Dim lineCount = File.ReadAllLines(speicherort).Length
If lineCount > 2048 Then
Dim lines As List(Of String) = File.ReadAllLines(speicherort).ToList
lines.RemoveRange(0, 8)
File.WriteAllLines(speicherort, lines)
End If
End Using
' MsgBox("Hier")
Catch ex As Exception
End Try
End Function
Public Shared Function sendmsg(ziel As String, message As String, Optional ByVal reciptient As String = "*")
Dim msgsend As New Process()
Dim msginfo As New ProcessStartInfo("msg.exe", reciptient & " /server:" & ziel & " " & message)
msginfo.CreateNoWindow = True
msginfo.Domain = "veragost"
msginfo.UserName = "miesenbeck"
msginfo.PasswordInClearText = "verag#3"
msginfo.UseShellExecute = False
msgsend.StartInfo = msginfo
msgsend.Start()
End Function
Public Shared Function getuptime()
Dim pc As PerformanceCounter = New PerformanceCounter("System", "System Up Time")
pc.NextValue() ' This returns zero for a reason I don't know
' This call to NextValue gets the correct value
Dim ts As TimeSpan = TimeSpan.FromSeconds(pc.NextValue())
Return ts.ToString()
End Function
Public Shared Function encode(ByVal str As String) As String
'supply True as the construction parameter to indicate
'that you wanted the class to emit BOM (Byte Order Mark)
'NOTE: this BOM value is the indicator of a UTF-8 string
Dim utf8Encoding As New System.Text.UTF8Encoding(True)
Dim encodedString() As Byte
encodedString = utf8Encoding.GetBytes(str)
Return utf8Encoding.GetString(encodedString)
End Function
Public Shared Function CheckTermServer(ByVal termserver As String, Optional ByVal port As Integer = 3389)
Dim TcpPortscan As New TcpClient
Try
TcpPortscan.Connect(termserver, port)
'MsgBox("yepp")
Return True
TcpPortscan.Close()
Catch ex As Exception
'MsgBox("nope")
Return False
End Try
End Function
Public Shared Function bringtofocus(ByVal processname As String)
Dim app As Process() = Process.GetProcessesByName(processname)
For Each p As Process In app
Try
AppActivate(p.Id)
Catch ex As Exception
' MsgBox(ex.Message)
End Try
Next
End Function
End Class

76
TSAnmeldung/cSQL.vb Normal file
View File

@@ -0,0 +1,76 @@
Imports System.Data.SqlClient
Public Class cSQL
Public Shared Sub SQL2DS(ByRef selector As String, ByRef ds As DataSet)
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = cRes.DBConString
cmd.Connection = con
Dim dataadapter As New SqlDataAdapter(selector, con)
con.Open()
dataadapter.Fill(ds)
con.Close()
End Sub
Public Shared Sub UpdateSQL(ByRef table As String, ByRef values As String, ByRef where As String)
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = cRes.DBConString
cmd.Connection = con
con.Open()
cmd.CommandText = "UPDATE " & table & " SET " & values & " WHERE " & where & ""
cmd.ExecuteNonQuery()
con.Close()
End Sub
Public Shared Sub InsertSQL(ByRef table As String, ByRef insert As String)
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = cRes.DBConString
cmd.Connection = con
con.Open()
cmd.CommandText = "INSERT INTO " & table & " " & insert & ""
cmd.ExecuteNonQuery()
con.Close()
End Sub
Public Shared Sub DeleteSQL(ByRef table As String, ByRef where As String)
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = cRes.DBConString
cmd.Connection = con
con.Open()
cmd.CommandText = "DELETE FROM " & table & " WHERE " & where & ""
cmd.ExecuteNonQuery()
con.Close()
End Sub
End Class
Public Class SQLVariable
Private Text, Value As String
Private prim As Boolean
Public Sub New(ByVal btext As String, ByVal bvalue As String, Optional bprim As Boolean = False)
Me.Value = bvalue
Me.Text = btext
End Sub
Public ReadOnly Property SQLText() As String
Get
Return Text
End Get
End Property
Public ReadOnly Property SQLValue() As Object
Get
Return Value
End Get
End Property
End Class