From ba8202cedb01322549a24e10ae85df71e484707e Mon Sep 17 00:00:00 2001 From: ms Date: Mon, 9 Jan 2023 23:03:36 +0100 Subject: [PATCH] =?UTF-8?q?Mit=20Kommando=20-c=20kann=20das=20Tool=20auch?= =?UTF-8?q?=20auf=20Clients=20ausgef=C3=BChrt=20werden,=20Benutzername=20u?= =?UTF-8?q?nd=20Kennwort=20m=C3=BCssen=20dann=20eingegeben=20werden.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TSAnmeldung/Anmeldung.Designer.vb | 97 +++++++++++++ TSAnmeldung/Anmeldung.resx | 120 ++++++++++++++++ TSAnmeldung/Anmeldung.vb | 94 +++++++++++++ TSAnmeldung/App.config | 6 +- .../{Form1.Designer.vb => Main.Designer.vb} | 40 ++++-- TSAnmeldung/{Form1.resx => Main.resx} | 3 + TSAnmeldung/{Form1.vb => Main.vb} | 90 +++++++++--- .../My Project/Application.Designer.vb | 26 ++-- TSAnmeldung/My Project/Application.myapp | 7 +- TSAnmeldung/My Project/Resources.Designer.vb | 14 +- TSAnmeldung/My Project/Resources.resx | 13 +- TSAnmeldung/My Project/Settings.Designer.vb | 72 +++++----- TSAnmeldung/My Project/app.manifest | 79 +++++++++++ TSAnmeldung/TSAnmeldung.vbproj | 51 +++++-- TSAnmeldung/cBenutzer.vb | 6 +- TSAnmeldung/cChilkat_Helper.vb | 28 ++++ TSAnmeldung/cPascom.vb | 133 ++++++++++++++++++ TSAnmeldung/cRes.vb | 27 ++-- 18 files changed, 796 insertions(+), 110 deletions(-) create mode 100644 TSAnmeldung/Anmeldung.Designer.vb create mode 100644 TSAnmeldung/Anmeldung.resx create mode 100644 TSAnmeldung/Anmeldung.vb rename TSAnmeldung/{Form1.Designer.vb => Main.Designer.vb} (77%) rename TSAnmeldung/{Form1.resx => Main.resx} (99%) rename TSAnmeldung/{Form1.vb => Main.vb} (78%) create mode 100644 TSAnmeldung/My Project/app.manifest create mode 100644 TSAnmeldung/cChilkat_Helper.vb create mode 100644 TSAnmeldung/cPascom.vb diff --git a/TSAnmeldung/Anmeldung.Designer.vb b/TSAnmeldung/Anmeldung.Designer.vb new file mode 100644 index 0000000..ef20a1b --- /dev/null +++ b/TSAnmeldung/Anmeldung.Designer.vb @@ -0,0 +1,97 @@ + _ +Partial Class Anmeldung + Inherits System.Windows.Forms.Form + + 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. + _ + 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. + _ + Private Sub InitializeComponent() + Me.TextBox1 = New System.Windows.Forms.TextBox() + Me.TextBox2 = New System.Windows.Forms.TextBox() + Me.Label1 = New System.Windows.Forms.Label() + Me.Label2 = New System.Windows.Forms.Label() + Me.Button1 = New System.Windows.Forms.Button() + Me.SuspendLayout() + ' + 'TextBox1 + ' + Me.TextBox1.Location = New System.Drawing.Point(34, 55) + Me.TextBox1.Name = "TextBox1" + Me.TextBox1.Size = New System.Drawing.Size(100, 20) + Me.TextBox1.TabIndex = 0 + ' + 'TextBox2 + ' + Me.TextBox2.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.TextBox2.Location = New System.Drawing.Point(34, 99) + Me.TextBox2.Name = "TextBox2" + Me.TextBox2.Size = New System.Drawing.Size(100, 20) + Me.TextBox2.TabIndex = 1 + Me.TextBox2.UseSystemPasswordChar = True + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(34, 36) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(75, 13) + Me.Label1.TabIndex = 2 + Me.Label1.Text = "Benutzername" + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(34, 82) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(52, 13) + Me.Label2.TabIndex = 3 + Me.Label2.Text = "Kennwort" + ' + 'Button1 + ' + Me.Button1.Location = New System.Drawing.Point(162, 97) + Me.Button1.Name = "Button1" + Me.Button1.Size = New System.Drawing.Size(75, 23) + Me.Button1.TabIndex = 4 + Me.Button1.Text = "Anmelden" + Me.Button1.UseVisualStyleBackColor = True + ' + 'Anmeldung + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(290, 172) + Me.Controls.Add(Me.Button1) + Me.Controls.Add(Me.Label2) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.TextBox2) + Me.Controls.Add(Me.TextBox1) + Me.Name = "Anmeldung" + Me.Text = "Anmeldung" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + + Friend WithEvents TextBox1 As TextBox + Friend WithEvents TextBox2 As TextBox + Friend WithEvents Label1 As Label + Friend WithEvents Label2 As Label + Friend WithEvents Button1 As Button +End Class diff --git a/TSAnmeldung/Anmeldung.resx b/TSAnmeldung/Anmeldung.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/TSAnmeldung/Anmeldung.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TSAnmeldung/Anmeldung.vb b/TSAnmeldung/Anmeldung.vb new file mode 100644 index 0000000..37aaab3 --- /dev/null +++ b/TSAnmeldung/Anmeldung.vb @@ -0,0 +1,94 @@ +Imports System.ComponentModel + +Public Class Anmeldung + Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click + + End Sub + + Private Sub Anmeldung_Load(sender As Object, e As EventArgs) Handles MyBase.Load + + End Sub + + Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click + Dim user As String = TextBox1.Text + Dim password As String = TextBox2.Text + If user.Length > 0 And password.Length > 0 Then + cRes.LocalUser.Name = user + If Not user.Contains("\") Then + user = "VERAGOST\" & user + End If + cRes.LocalUser.BenutzeranmeldeName = user + RDPConnect("rdpintern.verag.ag", "remote.verag.ag", user, password) + Main.Report() + Threading.Thread.Sleep(5000) + Me.Close() + End If + End Sub + + Public Shared Function RDPConnect(host As String, Optional ByVal gateway As String = "", Optional ByVal Username As String = "", Optional ByVal Password As String = "", Optional ByVal Fenster As Boolean = False) + Dim mstsc As New Process + Dim AnmeldeDatenVorhanden As Boolean = False + Dim rdpASadmin As String = "" + Dim FensterString As String = "" + + If Fenster = True Then + FensterString = " /w:1280 /h:1024" + Else + FensterString = " /f" + End If + + 'If host = "rdpintern.verag.ag" Then + ' commandcmd("cmdkey /delete:" & host) + ' commandcmd("cmdkey /delete:TERMSRV/" & host) + 'ElseIf host.StartsWith("TS") Then + ' rdpASadmin = " /admin" + 'End If + + If Username.Length > 0 And Password.Length > 0 Then + AnmeldeDatenVorhanden = True + commandcmd("cmdkey /generic:" & host & " /user:" & Username & " /pass:" & Password) + If gateway.Length > 0 Then + commandcmd("cmdkey /generic:" & gateway & " /user:" & Username & " /pass:" & Password) + End If + Threading.Thread.Sleep(3000) + End If + + + + mstsc.StartInfo.FileName = "mstsc.exe" + mstsc.StartInfo.UseShellExecute = False + mstsc.StartInfo.Arguments = " /v: " & host & rdpASadmin & FensterString + + mstsc.Start() + + 'If AnmeldeDatenVorhanden = True Then + ' Threading.Thread.Sleep(3000) + + ' Dim Abmeldung As New Process + ' commandcmd("cmdkey /delete:" & host) + + 'End If + + + + End Function + + Public Function deleteHostCred(host As String) + commandcmd("cmdkey /delete:" & host) + commandcmd("cmdkey /delete:TERMSRV/" & host) + End Function + Public Shared Function commandcmd(command As String) + + Dim cmd As New Process + cmd.StartInfo.WindowStyle = ProcessWindowStyle.Hidden + cmd.StartInfo.FileName = "cmd.exe" + cmd.StartInfo.Arguments = "/c " & command + cmd.Start() + + End Function + + Private Sub Anmeldung_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing + deleteHostCred("rdpintern.verag.ag") + deleteHostCred("remote.verag.ag") + End Sub +End Class \ No newline at end of file diff --git a/TSAnmeldung/App.config b/TSAnmeldung/App.config index 5534e28..a932133 100644 --- a/TSAnmeldung/App.config +++ b/TSAnmeldung/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/TSAnmeldung/Form1.Designer.vb b/TSAnmeldung/Main.Designer.vb similarity index 77% rename from TSAnmeldung/Form1.Designer.vb rename to TSAnmeldung/Main.Designer.vb index 307a354..d1d9013 100644 --- a/TSAnmeldung/Form1.Designer.vb +++ b/TSAnmeldung/Main.Designer.vb @@ -31,13 +31,14 @@ Partial Class Main Me.cboxStandort = New System.Windows.Forms.ComboBox() Me.Timer2 = New System.Windows.Forms.Timer(Me.components) Me.TimerReport = New System.Windows.Forms.Timer(Me.components) + Me.TelAnmelden = New System.Windows.Forms.Button() + Me.Label1 = New System.Windows.Forms.Label() 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" @@ -50,13 +51,12 @@ Partial Class Main ' 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.Text = "Sitzung (neu) starten" Me.btnResetSession.UseVisualStyleBackColor = True ' 'Timer1 @@ -67,7 +67,6 @@ Partial Class Main ' 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" @@ -91,28 +90,51 @@ Partial Class Main ' 'TimerReport ' - Me.TimerReport.Enabled = True Me.TimerReport.Interval = 300000 ' + 'TelAnmelden + ' + Me.TelAnmelden.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.TelAnmelden.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.TelAnmelden.ImageAlign = System.Drawing.ContentAlignment.MiddleRight + Me.TelAnmelden.Location = New System.Drawing.Point(11, 148) + Me.TelAnmelden.Name = "TelAnmelden" + Me.TelAnmelden.Size = New System.Drawing.Size(184, 28) + Me.TelAnmelden.TabIndex = 34 + Me.TelAnmelden.Text = "Telefon neu anmelden" + Me.TelAnmelden.UseVisualStyleBackColor = True + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(13, 183) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(39, 13) + Me.Label1.TabIndex = 35 + Me.Label1.Text = "Label1" + ' 'Main ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.BackColor = System.Drawing.SystemColors.ControlLightLight - Me.ClientSize = New System.Drawing.Size(208, 156) + Me.ClientSize = New System.Drawing.Size(208, 214) Me.ControlBox = False + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.TelAnmelden) 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.MaximumSize = New System.Drawing.Size(224, 300) Me.MinimizeBox = False - Me.MinimumSize = New System.Drawing.Size(224, 195) + Me.MinimumSize = New System.Drawing.Size(224, 230) Me.Name = "Main" Me.ShowIcon = False Me.Text = "TSAnmeldung" Me.ResumeLayout(False) + Me.PerformLayout() End Sub @@ -123,4 +145,6 @@ Partial Class Main Friend WithEvents cboxStandort As ComboBox Friend WithEvents Timer2 As Timer Friend WithEvents TimerReport As Timer + Friend WithEvents TelAnmelden As Button + Friend WithEvents Label1 As Label End Class diff --git a/TSAnmeldung/Form1.resx b/TSAnmeldung/Main.resx similarity index 99% rename from TSAnmeldung/Form1.resx rename to TSAnmeldung/Main.resx index 9a1e0ca..860677a 100644 --- a/TSAnmeldung/Form1.resx +++ b/TSAnmeldung/Main.resx @@ -126,6 +126,9 @@ 195, 17 + + 341 + diff --git a/TSAnmeldung/Form1.vb b/TSAnmeldung/Main.vb similarity index 78% rename from TSAnmeldung/Form1.vb rename to TSAnmeldung/Main.vb index ca22c04..756130a 100644 --- a/TSAnmeldung/Form1.vb +++ b/TSAnmeldung/Main.vb @@ -13,10 +13,13 @@ Public Class Main Public ConBroker As String Public ConString As String Public ConType As String + Public MAC As String + Public ClientMode As Boolean Dim lastupdate As DateTime Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load + Label1.Text = "" Me.Text = "TSAnmeldung " & My.Resources.ProgVersion SendEvents() @@ -42,36 +45,57 @@ Public Class Main If s = "/d" Or s = "-d" Then autoconnect = False autologoff = False + cRes.LocalUser.FillWithLoggedOnUser(False) : Report() : TimerReport.Enabled = True + ElseIf s = "/c" Or s = "-c" Then + autoconnect = False + autologoff = False + ClientMode = True + cboxStandort.Enabled = False + cRes.LocalUser.FillWithLoggedOnUser(False) + Anmeldung.deleteHostCred("rdpintern.verag.ag") + Anmeldung.deleteHostCred("remote.verag.ag") Else autoconnect = True + cRes.LocalUser.FillWithLoggedOnUser(False) : Report() : TimerReport.Enabled = True End If End If i += 1 Next + If Environment.GetCommandLineArgs.Length = 1 Then + cRes.LocalUser.FillWithLoggedOnUser(False) : Report() : TimerReport.Enabled = True + End If ' MsgBox(autoconnect) Timer1.Enabled = autoconnect - cRes.LocalUser.FillWithLoggedOnUser() + 'cRes.LocalUser.FillWithLoggedOnUser(False) cRes.LocalTeamviewerID = getTeamViewerID() - Report() + ' Report() + + + Dim meh As New cPascom + meh.Anmelden() End Sub - Function Report() + Public 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, SystemUpTime) VALUES ( + cSQL.InsertSQL("TbL_ThinClients", "(Benutzeranmeldename, Name, TeamviewerID, LastReport, ClientName, Domain, Company, SystemUpTime) VALUES ( '" & cRes.LocalUser.BenutzeranmeldeName & "', '" & cRes.LocalUser.Name & "', '" & cRes.LocalTeamviewerID & "', '" & Date.Now & "', '" & cRes.LocalUser.Hostname & "', +'" & cRes.LocalUser.Domäne & "', +'" & cRes.LocalUser.Company & "', '" & cRes.getuptime(True) & "')") End Function @@ -181,7 +205,13 @@ Public Class Main Private Sub btnResetSession_Click(sender As Object, e As EventArgs) Handles btnResetSession.Click killpro("mstsc") 'rdp("rdpintern.verag.ag", "/noConsentPrompt /multimon /control") - connect() + If ClientMode = False Then + connect() + Else + Dim frm As New Anmeldung + frm.Show() + Me.WindowState = FormWindowState.Minimized + End If End Sub Private Sub connect() @@ -191,6 +221,7 @@ Public Class Main If ConType = "rdp" Then rdp(-1, -1, ReturnTerminalserver()) Else + ' MsgBox(ConString) rdp(ConString, "/multimon") End If Case Else @@ -199,7 +230,7 @@ Public Class Main Else autologoff = False autoconnect = False - MsgBox("Verbindung konnte nicht aufgebaut werden (Server ist nicht erreichbar)") + MsgBox("Verbindung konnte nicht aufgebaut werden (Server" & ReturnTerminalserver() & " ist nicht erreichbar)") End If End Select @@ -257,7 +288,11 @@ Public Class Main 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") + Try + System.Diagnostics.Process.Start("shutdown", "-l") + Catch + End Try + End If End Sub @@ -279,19 +314,22 @@ Public Class Main 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 lines = IO.File.ReadAllLines("\\dc01.verag.ost.dmn\NETLOGON\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 + 'Select Case objFields(0).ToString + ' Case Benutzername + If String.Compare(Benutzername, objFields(0).ToString, True) = 0 Then + _ConType = objFields(1).ToString + _ConString = objFields(2).ToString + Return True + Exit Function + End If + + ' End Select Next Return False Catch ex As Exception @@ -304,14 +342,34 @@ Public Class Main Report() End Sub + Private Sub TelAnmelden_Click(sender As Object, e As EventArgs) Handles TelAnmelden.Click + Dim meh As New cPascom + meh.Anmelden() + 'If meh.Anmelden() = True Then + ' Label1.Text = "Telefon (neu) verbunden" + 'Else + ' Label1.Text = "Telefon nicht ermittelbar" + 'End If + End Sub + + 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) + If My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\TeamViewer", "ClientID", Nothing) Is Nothing Then + Reg = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\TeamViewer", "ClientID", Nothing) + Else + Reg = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\TeamViewer", "ClientID", Nothing) + End If Else Reg = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\TeamViewer", "ClientIDOfTSUser", Nothing) End If + Label1.Text = "TV ID: " & Reg + Label1.Visible = True + Return Reg + + End Function End Class diff --git a/TSAnmeldung/My Project/Application.Designer.vb b/TSAnmeldung/My Project/Application.Designer.vb index e786274..bc92648 100644 --- a/TSAnmeldung/My Project/Application.Designer.vb +++ b/TSAnmeldung/My Project/Application.Designer.vb @@ -1,10 +1,10 @@ '------------------------------------------------------------------------------ ' -' 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. ' '------------------------------------------------------------------------------ @@ -13,15 +13,15 @@ Option Explicit On Namespace My - - 'NOTE: This file is auto-generated; do not modify it directly. To make changes, - ' or if you encounter build errors in this file, go to the Project Designer - ' (go to Project Properties or double-click the My Project node in - ' Solution Explorer), and make changes on the Application tab. + + 'HINWEIS: Diese Datei wird automatisch generiert und darf nicht direkt bearbeitet werden. Wenn Sie Änderungen vornehmen möchten + ' oder in dieser Datei Buildfehler auftreten, wechseln Sie zum Projekt-Designer. + ' (Wechseln Sie dazu zu den Projekteigenschaften, oder doppelklicken Sie auf den Knoten "Mein Projekt" im + ' Projektmappen-Explorer). Nehmen Sie auf der Registerkarte "Anwendung" entsprechende Änderungen vor. ' Partial Friend Class MyApplication - - _ + + _ Public Sub New() MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) Me.IsSingleInstance = false @@ -29,8 +29,8 @@ Namespace My Me.SaveMySettingsOnExit = true Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses End Sub - - _ + + _ Protected Overrides Sub OnCreateMainForm() Me.MainForm = Global.TSAnmeldung.Main End Sub diff --git a/TSAnmeldung/My Project/Application.myapp b/TSAnmeldung/My Project/Application.myapp index 1243847..00fcc91 100644 --- a/TSAnmeldung/My Project/Application.myapp +++ b/TSAnmeldung/My Project/Application.myapp @@ -1,11 +1,10 @@  - + true - Form1 + Main false 0 true 0 - 0 true - + \ No newline at end of file diff --git a/TSAnmeldung/My Project/Resources.Designer.vb b/TSAnmeldung/My Project/Resources.Designer.vb index 06965ca..b455779 100644 --- a/TSAnmeldung/My Project/Resources.Designer.vb +++ b/TSAnmeldung/My Project/Resources.Designer.vb @@ -22,7 +22,7 @@ Namespace My.Resources ''' ''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. ''' - _ @@ -60,6 +60,16 @@ Namespace My.Resources End Set End Property + ''' + ''' Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + ''' + Public ReadOnly Property Hakerl20() As System.Drawing.Bitmap + Get + Dim obj As Object = ResourceManager.GetObject("Hakerl20", resourceCulture) + Return CType(obj,System.Drawing.Bitmap) + End Get + End Property + ''' ''' Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. ''' @@ -71,7 +81,7 @@ Namespace My.Resources End Property ''' - ''' Sucht eine lokalisierte Zeichenfolge, die 1.0.1.7 ähnelt. + ''' Sucht eine lokalisierte Zeichenfolge, die 1.1.0.0 ähnelt. ''' Public ReadOnly Property ProgVersion() As String Get diff --git a/TSAnmeldung/My Project/Resources.resx b/TSAnmeldung/My Project/Resources.resx index 6851b87..c85c2bd 100644 --- a/TSAnmeldung/My Project/Resources.resx +++ b/TSAnmeldung/My Project/Resources.resx @@ -117,17 +117,20 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ..\Resources\LogOff20.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - 1.0.1.7 + 1.1.0.0 + ..\Resources\Reload20.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\ShutDown20.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\LogOff20.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\..\..\..\..\Pictures\Programmbilder\Hakerl20.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/TSAnmeldung/My Project/Settings.Designer.vb b/TSAnmeldung/My Project/Settings.Designer.vb index 87a7c6a..cc587e0 100644 --- a/TSAnmeldung/My Project/Settings.Designer.vb +++ b/TSAnmeldung/My Project/Settings.Designer.vb @@ -1,10 +1,10 @@ '------------------------------------------------------------------------------ ' -' 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. ' '------------------------------------------------------------------------------ @@ -13,42 +13,42 @@ Option Explicit On Namespace My - - _ + + _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase - - Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) - -#Region "My.Settings Auto-Save Functionality" + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + +#Region "Automatische My.Settings-Speicherfunktion" #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 - _ - Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) - If My.Application.SaveMySettingsOnExit Then - My.Settings.Save() - End If - End Sub + _ + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub #End If #End Region - + Public Shared ReadOnly Property [Default]() As MySettings Get - + #If _MyType = "WindowsForms" Then - If Not addedHandler Then - SyncLock addedHandlerLockObject - If Not addedHandler Then - AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings - addedHandler = True - End If - End SyncLock - End If + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If #End If Return defaultInstance End Get @@ -57,13 +57,13 @@ Namespace My End Namespace Namespace My - - _ + + _ Friend Module MySettingsProperty - - _ + + _ Friend ReadOnly Property Settings() As Global.TSAnmeldung.My.MySettings Get Return Global.TSAnmeldung.My.MySettings.Default diff --git a/TSAnmeldung/My Project/app.manifest b/TSAnmeldung/My Project/app.manifest new file mode 100644 index 0000000..0a605c3 --- /dev/null +++ b/TSAnmeldung/My Project/app.manifest @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TSAnmeldung/TSAnmeldung.vbproj b/TSAnmeldung/TSAnmeldung.vbproj index ad55780..a2e0d30 100644 --- a/TSAnmeldung/TSAnmeldung.vbproj +++ b/TSAnmeldung/TSAnmeldung.vbproj @@ -11,9 +11,11 @@ TSAnmeldung 512 WindowsForms - v4.6.1 + v4.7.2 true true + false + publish\ true Disk @@ -26,7 +28,6 @@ true 0 1.0.0.%2a - false false true @@ -39,6 +40,7 @@ bin\Debug\ TSAnmeldung.xml 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + false AnyCPU @@ -49,6 +51,7 @@ bin\Release\ TSAnmeldung.xml 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + false On @@ -65,8 +68,18 @@ Admin.ico + + My Project\app.manifest + - + + False + ..\..\..\..\..\..\Verag\ChilkatDotNet47.dll + True + + + False + @@ -94,20 +107,29 @@ - - - - + + Anmeldung.vb + + Form - - Form1.vb + + + + + + + Form + + + Main.vb Form True Application.myapp + True True @@ -121,8 +143,11 @@ - - Form1.vb + + Anmeldung.vb + + + Main.vb PublicVbMyResourcesResXFileCodeGenerator @@ -132,6 +157,7 @@ + MyApplicationCodeGenerator Application.Designer.vb @@ -170,5 +196,8 @@ false + + + \ No newline at end of file diff --git a/TSAnmeldung/cBenutzer.vb b/TSAnmeldung/cBenutzer.vb index 49b7a26..a77d05b 100644 --- a/TSAnmeldung/cBenutzer.vb +++ b/TSAnmeldung/cBenutzer.vb @@ -17,11 +17,12 @@ Public Class cBenutzer Property suchname As String = "" Property Hostname As String = "" Property SystemUpTime As String = "" + Property Company As String = "" - 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 = True, 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 @@ -120,6 +121,7 @@ Public Class cBenutzer .PropertiesToLoad.Add("distinguishedName") .PropertiesToLoad.Add("msDS-PrincipalName") .PropertiesToLoad.Add("userPrincipalName") + .PropertiesToLoad.Add("company") End With Dim Result As DirectoryServices.SearchResult = searcher.FindOne @@ -134,11 +136,13 @@ Public Class cBenutzer Me.BenutzeranmeldeName = blablabla(Result, "msDS-PrincipalName") Me.msDSPrincipalName = blablabla(Result, "msDS-PrincipalName") Me.userPrincipalName = blablabla(Result, "userPrincipalName") + Me.Company = blablabla(Result, "company") Catch ex As Exception MsgBox("FillFromDC: " & ex.Message) End Try + 'MsgBox(Me.Company) End Function Function isDokuAdmin() As Boolean diff --git a/TSAnmeldung/cChilkat_Helper.vb b/TSAnmeldung/cChilkat_Helper.vb new file mode 100644 index 0000000..d6ec367 --- /dev/null +++ b/TSAnmeldung/cChilkat_Helper.vb @@ -0,0 +1,28 @@ +Imports Chilkat + +Public Class cChilkat_Helper + + 'Declare Function meh Lib "ChilkatDotNet47.dll" () As Integer + + Public Shared Sub UnlockCilkat() + Dim glob As Chilkat.[Global] = New Chilkat.[Global]() + Dim success As Boolean = glob.UnlockBundle("VERAGS.CB1122022_JJ6kgS2zoR0g") + + If success <> True Then + Debug.WriteLine(glob.LastErrorText) + Return + End If + + Dim status As Integer = glob.UnlockStatus + + If status = 2 Then + Debug.WriteLine("Unlocked using purchased unlock code.") + Else + Debug.WriteLine("Unlocked in trial mode.") + End If + + Debug.WriteLine(glob.LastErrorText) + + + End Sub +End Class diff --git a/TSAnmeldung/cPascom.vb b/TSAnmeldung/cPascom.vb new file mode 100644 index 0000000..1dd4c89 --- /dev/null +++ b/TSAnmeldung/cPascom.vb @@ -0,0 +1,133 @@ +Imports System.Reflection +Imports System.IO +Imports Chilkat +Public Class cPascom + + ' Declare Function meh Lib "ChilkatDotNet47.dll" () As Integer + + Dim API_USER_AUTHORIZATION = "bW9ieTpnWlhTSVprTnhmaUQxOEU=" + Dim Arbeitsplatz As String = "" + + Public Function Anmelden() As Boolean + If GetTelArbeitsplatz4Host() Then + Try + + 'Benutzername: moby + + 'Passwort: XgDsFmMSutaMLA1 + + 'BASIC Auth String: bW9ieTpYZ0RzRm1NU3V0YU1MQTE = + + cChilkat_Helper.UnlockCilkat() + Dim API_STRING = "pbx3.flashnet.at" + + Dim rest As New Chilkat.Rest + Dim success As Boolean + + Dim bTls As Boolean = True + Dim port As Integer = 443 + Dim bAutoReconnect As Boolean = True + + + success = rest.Connect(API_STRING, port, bTls, bAutoReconnect) + If (success <> True) Then + Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason) + Debug.WriteLine(rest.LastErrorText) + + Return False + End If + + rest.AddHeader("Content-Type", "application/json") + rest.SetAuthBasic("moby", "XgDsFmMSutaMLA1") + + + Dim json As New Chilkat.JsonObject + + Dim successJsonLoad As Boolean = json.Load(" + {""action"":""relocate"",""username"":""" & Environment.UserName & """}}") + + If (successJsonLoad <> True) Then + MsgBox(json.LastErrorText) + Return False + End If + + + Dim sbRequestBody As New Chilkat.StringBuilder + json.EmitSb(sbRequestBody) + + ' MsgBox(sbRequestBody.ToString) + Dim sbResponseBody As New Chilkat.StringBuilder + success = rest.FullRequestSb("POST", "/verag/services/location/" & Arbeitsplatz, sbRequestBody, sbResponseBody) + If (success <> True) Then + Debug.WriteLine(rest.LastErrorText) + Return False + End If + Dim respStatusCode As Integer = rest.ResponseStatusCode + + If (respStatusCode <> 200) Then + + ' MsgBox(sbResponseBody.GetAsString()) + + Return False + End If + + + Dim jsonResp = New Chilkat.JsonObject() + jsonResp.LoadSb(sbResponseBody) + + Dim Logfile As String = "C:\Verag\ErrorLog.txt" + 'File.AppendAllText(Logfile, String.Format(rest.ResponseStatusCode & " " & sbRequestBody.ToString)) + Using writer As New StreamWriter(Logfile, True) + writer.WriteLine(rest.ResponseStatusCode & " " & Arbeitsplatz & " " & DateTime.Now.ToString & " " & sbRequestBody.ToString) + End Using + + Dim gatewayId = jsonResp.StringOf("gatewayId") + Dim Resp_error = jsonResp.StringOf("error") + Dim Resp_errorCode = jsonResp.StringOf("errorCode") + + + + + Return True + + + + + Catch ex As Exception + MsgBox(ex.Message) + Return False + End Try + Return True + Else + Return False + End If + + + End Function + + Public Function GetTelArbeitsplatz4Host() As Boolean + Try + Dim lines = IO.File.ReadAllLines("\\dc01.verag.ost.dmn\NETLOGON\Telefonarbeitsplaetze.ini") + Dim colCount = lines.First.Split(";"c).Length + + For Each line In lines + Dim objFields = From field In line.Split(";"c) + + + If String.Compare(cRes.LocalUser.Hostname, objFields(0).ToString, True) = 0 Then + Arbeitsplatz = 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 + End Function + + +End Class diff --git a/TSAnmeldung/cRes.vb b/TSAnmeldung/cRes.vb index 4a6255c..8e6b1d8 100644 --- a/TSAnmeldung/cRes.vb +++ b/TSAnmeldung/cRes.vb @@ -7,7 +7,6 @@ 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 DBConString As String = "Server=sqlcluster.verag.ost.dmn\verag;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;" @@ -45,7 +44,7 @@ Public Class cRes '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.PasswordInClearText = "BmWr501956" oStartInfo.CreateNoWindow = True oStartInfo.UseShellExecute = False oStartInfo.RedirectStandardOutput = True @@ -90,7 +89,7 @@ Public Class cRes msginfo.CreateNoWindow = True msginfo.Domain = "veragost" msginfo.UserName = "miesenbeck" - msginfo.PasswordInClearText = "verag#3" + ' msginfo.PasswordInClearText = "verag#3" msginfo.UseShellExecute = False msgsend.StartInfo = msginfo msgsend.Start() @@ -100,15 +99,19 @@ Public Class cRes Dim pc As PerformanceCounter = New PerformanceCounter("System", "System Up Time") pc.NextValue() ' This returns zero for a reason I don't know + Try + ' This call to NextValue gets the correct value + Dim ts As TimeSpan = TimeSpan.FromSeconds(pc.NextValue()) + If Shorty = True Then + Dim upTime = String.Format("{0:D2}d-{1:D2}h:{2:D2}m", ts.Days, ts.Hours, ts.Minutes) + Return upTime + Exit Function + End If + Return ts.ToString() + Catch ex As Exception + MsgBox(ex.Message) + End Try - ' This call to NextValue gets the correct value - Dim ts As TimeSpan = TimeSpan.FromSeconds(pc.NextValue()) - If Shorty = True Then - Dim upTime = String.Format("{0:D2}d-{1:D2}h:{2:D2}m", ts.Days, ts.Hours, ts.Minutes) - Return upTime - Exit Function - End If - Return ts.ToString() End Function Public Shared Function encode(ByVal str As String) As String @@ -148,4 +151,6 @@ Public Class cRes Next End Function + + End Class