Compare commits

...

3 Commits

5 changed files with 120 additions and 60 deletions

1
Main.Designer.vb generated
View File

@@ -106,7 +106,6 @@ Partial Class TSUserReporter
Me.btnTest.TabIndex = 4
Me.btnTest.Text = "Test"
Me.btnTest.UseVisualStyleBackColor = True
Me.btnTest.Visible = False
'
'Button1
'

117
Main.vb
View File

@@ -1,5 +1,7 @@
Imports System.Environment
Imports System.Globalization
Imports System.IO
Imports Microsoft.Win32
Public Class TSUserReporter
@@ -9,10 +11,12 @@ Public Class TSUserReporter
Public Printer As New List(Of Drucker)
Dim Standarddrucker As New Drucker("", "")
Dim Bondrucker As New Drucker("", "")
Dim Niederlassung As New Drucker("", "")
Public Message As String
Dim ThinClient As String
Dim isTS As Boolean = False
Dim ID As String = ""
Dim AutoUpdate As Boolean = True
Private Sub TSUserReporter_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Visible = False
@@ -24,7 +28,7 @@ Public Class TSUserReporter
FillLabel()
ID = StartTime.ToString("dd.MM HH:mm:ss") & cRes.LocalUser.BenutzeranmeldeName
ID = StartTime.ToString("yyyy.MM.dd HH:mm:ss ") & cRes.LocalUser.BenutzeranmeldeName
LogLogOn()
End Sub
@@ -34,9 +38,12 @@ Public Class TSUserReporter
Sub Routine()
Try
cRes.LocalUser.FillWithLoggedOnUser(True)
cRes.LocalUser.FillWithLoggedOnUser(True, "LDAP://DC=VERAG,DC=OST,DC=DMN")
' MsgBox("1")
cRes.LocalTeamviewerID = getregkey()
' MsgBox("2")
cRes.LocalDomUser.getDomUserByBenutzerAnmeldename(Environment.UserDomainName, Environment.UserName)
'MsgBox("3")
isTS = cRes.LocalUser.Hostname Like "TS*"
'isTS = True
@@ -49,7 +56,7 @@ Public Class TSUserReporter
CheckAutoLogOffAndIfthenAutoLogOff()
End If
Catch ex As Exception
'MsgBox(ex.Message)
MsgBox("Routine:" & ex.Message)
End Try
End Sub
@@ -77,14 +84,23 @@ Public Class TSUserReporter
End Function
Function getregkey()
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
Dim regObj As Object = Nothing
' 1. HKCU
regObj = Registry.GetValue("HKEY_CURRENT_USER\Software\TeamViewer", "ClientIDOfTSUser", Nothing)
If regObj IsNot Nothing Then Return regObj.ToString()
' 2. HKLM\WOW6432Node
regObj = Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\TeamViewer", "ClientID", Nothing)
If regObj IsNot Nothing Then Return regObj.ToString()
' 3. HKLM (Standard-Pfad, 64-bit)
regObj = Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\TeamViewer", "ClientID", Nothing)
If regObj IsNot Nothing Then Return regObj.ToString()
' Falls nichts gefunden
Return Nothing
Return Reg
End Function
Function Report()
@@ -110,7 +126,7 @@ Public Class TSUserReporter
'" & cRes.LocalUser.BenutzeranmeldeName & "',
'" & cRes.LocalUser.Name & "',
'" & cRes.LocalTeamviewerID & "',
'" & Date.Now & "',
'" & Date.Now.ToString("dd.MM.yyyy HH:mm:ss", New CultureInfo("de").NumberFormat) & "',
'" & cRes.LocalUser.Domäne & "',
'" & cRes.LocalUser.Company & "',
'" & StartTime.ToString("dd.MM HH:mm") & "',
@@ -135,7 +151,8 @@ Public Class TSUserReporter
Label1.Text &= "Letzte Aktualisierung:" & vbCrLf
Label1.Text &= lastupdate & vbCrLf
Label1.Text &= Standarddrucker.Druckername & vbCrLf
Label1.Text &= Bondrucker.Druckername & vbCrLf & vbCrLf
Label1.Text &= Bondrucker.Druckername & vbCrLf
Label1.Text &= "TimasID: " & cRes.LocalUser.TimasID & vbCrLf
Label1.Text &= Message
End Function
@@ -178,22 +195,32 @@ Public Class TSUserReporter
End Sub
Private Sub UpdateTimer_Tick(sender As Object, e As EventArgs) Handles UpdateTimer.Tick
Routine()
If AutoUpdate = True Then
Routine()
End If
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
Dim PrinterShortName As String = ""
For Each printer As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters
Dim position As Integer = printer.LastIndexOf("\")
If position > 0 Then
printer = printer.Substring(position + 1)
End If
PrinterShortName &= printer & vbCrLf
Next
MsgBox(PrinterShortName)
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_SERVER", Nothing, EnvironmentVariableTarget.User)
Environment.SetEnvironmentVariable("PC_USER", Nothing, EnvironmentVariableTarget.User)
Environment.SetEnvironmentVariable("timasID", cRes.LocalUser.TimasID, 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"))
@@ -206,31 +233,7 @@ Public Class TSUserReporter
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
@@ -243,7 +246,15 @@ Public Class TSUserReporter
'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)
Dim printername As String = objFields(1).ToString
Dim position As Integer = printername.LastIndexOf("\")
If position > 0 Then
printername = printername.Substring(position + 1)
End If
Dim p As New Drucker(printername, objFields(2).ToString)
Printer.Add(p)
'_ConString = objFields(2).ToString
' Return True
@@ -272,12 +283,25 @@ Public Class TSUserReporter
End Function
Public Function SetDefaultPrinter()
Dim sp As String = ""
For Each p As Drucker In Printer
If p.Druckertype = "" Or p.Druckertype = "Standard" Then
''ip = installed printer
''sp = standard printer
For Each ip As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters
If ip.LastIndexOf(p.Druckername, StringComparison.OrdinalIgnoreCase) > 0 Then
sp = ip
End If
Next
Standarddrucker = p
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device", p.Druckername)
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows", "Device", sp)
ElseIf p.Druckertype = "Bon" Then
Bondrucker = p
ElseIf p.Druckertype = "Niederlassung" Then
Niederlassung = p
End If
Next
writeoutAVISO_OPTIONS()
@@ -309,7 +333,8 @@ Public Class TSUserReporter
Text = ""
Else
Text = "PRINTER:" & Standarddrucker.Druckername & vbCrLf
Text &= "BON:" & Bondrucker.Druckername
Text &= "BON:" & Bondrucker.Druckername & vbCrLf
Text &= "Niederlassung:" & Niederlassung.Druckername
End If
Try
System.IO.File.WriteAllText(PrintINI, Text)

View File

@@ -14,9 +14,10 @@
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>\\app01\Tools\Test\</PublishUrl>
<Install>false</Install>
<InstallFrom>Unc</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
@@ -24,14 +25,14 @@
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DefineDebug>true</DefineDebug>
@@ -69,7 +70,10 @@
<SignManifests>true</SignManifests>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>443CA3745EE904EED98572A89099259301BA06D1</ManifestCertificateThumbprint>
<ManifestCertificateThumbprint>0E7F805EC73FC627C5B07472C1EF817DF8E04CE2</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />

View File

@@ -17,8 +17,9 @@ Public Class cBenutzer
Property suchname As String = ""
Property Hostname As String = ""
Property Company As String = ""
Property Username As String = ""
Property sAMAccountName As String = ""
Property TimasID As String = ""
'test
@@ -26,17 +27,31 @@ Public Class cBenutzer
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
Catch ex As Exception
MsgBox("FillWithLoggedOnUser:" & ex.Message)
End Try
Domäne = System.DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain.ToString
BenutzeranmeldeName = Environment.UserDomainName & "\" & Environment.UserName
Username = Environment.UserName
If dcabfrage = True Then
'Class1.DebugText = userPrincipalName & LDAPa
FillFromDC(userPrincipalName, "userPrincipalName", LDAPa)
Try
'Class1.DebugText = userPrincipalName & LDAPa
FillFromDC(userPrincipalName, "userPrincipalName", LDAPa)
FillTimasID()
Catch ex As Exception
MsgBox("dcabfrage: " & ex.Message)
End Try
End If
End Function
@@ -100,6 +115,7 @@ Public Class cBenutzer
.PropertiesToLoad.Add("msDS-PrincipalName")
.PropertiesToLoad.Add("userPrincipalName")
.PropertiesToLoad.Add("company")
.PropertiesToLoad.Add("sAMAccountName")
End With
Dim Result As DirectoryServices.SearchResult = searcher.FindOne
@@ -115,9 +131,25 @@ Public Class cBenutzer
Me.msDSPrincipalName = blablabla(Result, "msDS-PrincipalName")
Me.userPrincipalName = blablabla(Result, "userPrincipalName")
Me.Company = blablabla(Result, "company")
Me.sAMAccountName = blablabla(Result, "sAMAccountName")
Catch ex As Exception
MsgBox("FillFromDC: " & ex.Message)
'MsgBox("FillFromDC: " & ex.Message)
End Try
End Function
Function FillTimasID()
Try
Dim ds As New DataSet
cSQL.SQL2DS("SELECT mit_timasID FROM ADMIN.dbo.tblMitarbeiter where mit_AliasAD_Username = '" & Me.sAMAccountName & "'", ds)
If ds.Tables.Count > 0 Then
If ds.Tables(0).Rows(0).Item(0) > 0 Then
Me.TimasID = ds.Tables(0).Rows(0).Item(0)
End If
End If
Catch ex As Exception
' MsgBox("FillTimasID: " & ex.Message)
End Try
End Function

View File

@@ -108,7 +108,7 @@ Public Class cDomUser
Next
Catch ex As Exception
'MsgBox("getDomUserByBenutzerAnmeldename" & Dom & vbCrLf & ds.Tables(0).Rows.Count & Username & vbCrLf & ex.Message)
MsgBox("getDomUserByBenutzerAnmeldename" & Dom & vbCrLf & ds.Tables(0).Rows.Count & Username & vbCrLf & ex.Message)
End Try
' MsgBox("hier")