Skip to content

Commit c7450fc

Browse files
authored
Add files via upload
1 parent 4685cac commit c7450fc

13 files changed

Lines changed: 98 additions & 47 deletions

lusrmgr/About.Designer.vb

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lusrmgr/ActiveDirectory.vb

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Public Class ActiveDirectory
77
Private main As DirectoryEntry
88
Private mForm As Form1
99
Private isLoad As Boolean = True
10-
Private cancelToken As New Threading.CancellationTokenSource()
10+
Private cancelToken As Threading.CancellationTokenSource
1111

1212
Public conErr As Boolean
1313
Public displayName As String
@@ -57,7 +57,7 @@ Public Class ActiveDirectory
5757
End Function
5858

5959
Public Sub Disconnect()
60-
If isLoading() Then
60+
If isLoading() AndAlso cancelToken IsNot Nothing Then
6161
cancelToken.Cancel()
6262
End If
6363

@@ -104,11 +104,11 @@ Public Class ActiveDirectory
104104
Try
105105
Dim o As Object = main.NativeObject
106106

107-
If GroupList.Count + UserList.Count = 0 Then
108-
Return False
109-
Else
110-
Return True
111-
End If
107+
'If GroupList.Count + UserList.Count = 0 Then
108+
'Return False
109+
'Else
110+
Return True
111+
'End If
112112
Catch ex As Exception
113113
Return False
114114
End Try
@@ -122,11 +122,15 @@ Public Class ActiveDirectory
122122
Try
123123
RefreshBuiltInSecurityPrincipals()
124124

125+
cancelToken = New Threading.CancellationTokenSource()
125126
Await Task.Run(AddressOf RefreshDS, cancelToken.Token)
126127
Catch ex As Exception
127128
If Not cancelToken.IsCancellationRequested Then
129+
'Set the connection error flag
128130
conErr = True
129131
End If
132+
Finally
133+
cancelToken.Dispose()
130134
End Try
131135
End Sub
132136

@@ -265,9 +269,6 @@ Public Class ActiveDirectory
265269
End If
266270
End If
267271

268-
'If mForm.QSBar.Visible Then mForm.QuickSearch(Nothing, Nothing)
269-
'If mForm.QSMenu.Visible Then mForm.QuickSearch_Menu(Nothing, Nothing)
270-
271272
If Not mForm.isRootNode() Then
272273
mForm.hiddenItems.Clear()
273274
mForm.QSMenu.Clear()

lusrmgr/COMErr.vb

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
ILLEGAL_USERNAME = &H8007089A
1212
BLOCKED_BUILTIN = &H8007055B
1313
GROUPADD_KNOWNACCOUNT = &H8007056C
14+
ERROR_INCORRECT_ACCOUNT_TYPE = &H800721C6
1415
End Enum
1516

1617
Enum COMErrResult
@@ -22,7 +23,7 @@
2223
Sub ShowUnknownErr(HWND As IntPtr, exMsg As String)
2324
TASKDIALOG.TaskDialog(HWND, nullptr,
2425
"Local users and groups",
25-
"An unkown error ocurred",
26+
"An unkown error occurred",
2627
exMsg.Replace(vbNewLine, "") & vbCrLf & "Please report this issue to the developer.",
2728
TASKDIALOG_COMMON_BUTTON_FLAGS.TDCBF_OK_BUTTON, TD_ERROR_ICON, Nothing)
2829
End Sub
@@ -45,7 +46,7 @@
4546
tdc.nDefaultButton = TASKDIALOG_RESULT.IDCANCEL
4647

4748
tdc.pszWindowTitle = "Local users and groups"
48-
tdc.pszMainInstruction = "An unkown error ocurred"
49+
tdc.pszMainInstruction = "An unkown error occurred"
4950
tdc.pszContent = exMsg.Replace(vbNewLine, "") & vbCrLf & vbCrLf & "Error code: 0x" & Hex(errCode) & vbCrLf & "Please report this issue to the developer."
5051

5152
TaskDialogIndirect(tdc, result, 0, 0)
@@ -152,6 +153,45 @@
152153
Case ErrorCodes.GROUPADD_KNOWNACCOUNT
153154
TASKDIALOG.TaskDialog(HWND, nullptr, "Local users and groups", "Operation cannot be performed on built-in accounts", "System-defined groups cannot be members of predefined security principals.", TASKDIALOG_COMMON_BUTTON_FLAGS.TDCBF_OK_BUTTON, TASKDIALOG_ICONS.TD_ERROR_ICON, 0)
154155
Return False
156+
Case ErrorCodes.ERROR_INCORRECT_ACCOUNT_TYPE
157+
158+
Dim result As Integer
159+
160+
Dim tdc As New TASKDIALOGCONFIG
161+
tdc.cbSize = sizeof(tdc)
162+
163+
Dim buttons As TASKDIALOG_BUTTON() = {New TASKDIALOG_BUTTON(IDOK, "OK"), New TASKDIALOG_BUTTON(100, "Copy error code")}
164+
tdc.cButtons = buttons.Length
165+
tdc.pButtons = arrPtr(buttons, TASKDIALOG_BUTTON.SIZE * tdc.cButtons)
166+
167+
tdc.hwndParent = HWND
168+
tdc.pszMainIcon = TASKDIALOG_ICONS.TD_ERROR_ICON
169+
tdc.dwFlags = TASKDIALOG_FLAGS.TDF_ALLOW_DIALOG_CANCELLATION
170+
171+
tdc.pszWindowTitle = "Cannot make changes to account"
172+
tdc.pszMainInstruction = "System is not authoritative for the account"
173+
174+
tdc.pszContent = "The system is not authoritative for the specified account and therefore cannot complete the operation. Please retry the operation using the provider associated with this account. If this is an online provider please use the provider's online site." &
175+
vbCrLf & vbCrLf & "Error code: 0x" & Hex(errCode)
176+
177+
tdc.pszCollapsedControlText = "Why does this occurr?"
178+
tdc.pszExpandedControlText = "Why does this occurr?"
179+
tdc.pszExpandedInformation = "This issue can occurr whilst trying to make changes to a Microsoft account linked to your computer, not to a local account." &
180+
" To make changes to Microsoft accounts, use the Windows settings or visit your account page online."
181+
182+
TaskDialogIndirect(tdc, result, 0, 0)
183+
184+
For i As Integer = 0 To buttons.Length - 1
185+
buttons(i).freem()
186+
Next
187+
free(tdc.pButtons)
188+
189+
If result = 100 Then
190+
Clipboard.SetText("0x" & Hex(errCode))
191+
End If
192+
193+
Return False
194+
155195
Case Else
156196
ShowUnknownCOMErr(errCode, HWND, exMsg)
157197
Return COMErrResult.UNKOWN_ERR

lusrmgr/Connect.vb

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1-
Imports System.Threading
2-
Public Class Connect
3-
Private Delegate Sub dTextBox(text As String)
4-
Private thread As Thread
1+
Public Class Connect
2+
Private currentAsyncResult As IAsyncResult
53

6-
Private Sub searchForHostName(addr As String)
7-
On Error Resume Next
4+
Private Async Sub queueHostEntry(result As IAsyncResult)
5+
'This prevents multiple searches at a time by stopping all current searches
6+
currentAsyncResult = result
87

9-
Dim t As String = Net.Dns.GetHostEntry(addr).HostName
8+
While Not result.IsCompleted
9+
If currentAsyncResult IsNot result Then 'Determine whether scan is no longer required, since a new input has been given
10+
Return
11+
End If
1012

11-
If TextBox2.InvokeRequired Then
12-
TextBox2.Invoke(New dTextBox(Sub(text As String)
13-
TextBox2.Text = text
14-
End Sub), t)
15-
Else
16-
TextBox2.Text = t
17-
End If
13+
Await Task.Delay(100)
14+
End While
15+
16+
Try
17+
TextBox2.Text = Net.Dns.EndGetHostEntry(result).HostName
18+
Catch ex As Exception
19+
End Try
20+
21+
currentAsyncResult = Nothing
1822
End Sub
1923

2024
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
21-
If thread IsNot Nothing Then
22-
thread.Abort()
23-
End If
2425

2526
TextBox2.Clear()
2627

2728
If TextBox1.TextLength = 0 Then
2829
Button1.Enabled = False
30+
currentAsyncResult = Nothing 'Cancel current DNS lookup
2931
Else
3032
Button1.Enabled = True
31-
32-
thread = New Thread(Sub()
33-
searchForHostName(TextBox1.Text)
34-
End Sub)
35-
thread.Start()
33+
queueHostEntry(Net.Dns.BeginGetHostEntry(TextBox1.Text, Nothing, Nothing))
3634
End If
3735
End Sub
3836

@@ -60,7 +58,7 @@ Public Class Connect
6058
End Sub
6159

6260
Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
63-
thread.Abort()
61+
currentAsyncResult = Nothing 'Cancel current DNS lookup
6462
End Sub
6563

6664
Private Sub Label2_HelpRequested(sender As Object, hlpevent As HelpEventArgs) Handles TextBox2.HelpRequested, Label2.HelpRequested

lusrmgr/Form1.vb

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ Public Class Form1
142142
End Sub
143143

144144
Private Async Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
145-
146145
Dim ComputerName As String = My.Computer.Name
147146
If ComputerName = Nothing Then ComputerName = "Local Computer"
148147
tw.Nodes(0).Text = ComputerName & " (this computer)"
@@ -158,7 +157,7 @@ Public Class Form1
158157

159158
While localAD.isLoading()
160159

161-
Await Task.Delay(600)
160+
Await Task.Delay(100)
162161

163162
If c.isBackground AndAlso tw.Nodes(0).Tag = cTag.Connected Then
164163
If Not c.isClosing Then c.Close()
@@ -171,10 +170,12 @@ Public Class Form1
171170
End If
172171

173172
Select Case loadingL.Tag
174-
Case Is < 3
173+
Case Is < 24
175174
loadingL.Tag += 1
176-
loadingL.Text &= "."
177-
Case 3
175+
If loadingL.Tag = 6 OrElse loadingL.Tag = 12 OrElse loadingL.Tag = 18 Then
176+
loadingL.Text &= "."
177+
End If
178+
Case 24
178179
loadingL.Tag = 0
179180
loadingL.Text = loadingL.Text.Remove(loadingL.Text.Length - 3)
180181
End Select
@@ -787,6 +788,8 @@ Public Class Form1
787788
Dim addr As String = Connect.TextBox1.Text
788789
c = New Connecting(Me)
789790

791+
792+
'/////// DNS lookup ///////////////////////////////////
790793
Try
791794
c.SetText("Resolving host name")
792795

@@ -814,19 +817,25 @@ Public Class Form1
814817

815818
Return
816819
End Try
820+
'//////////////////////////////////////////////////
821+
817822

823+
'/////// Set display name /////////////////////////
818824
Dim dspName As String = addr
819825
If Connect.TextBox2.TextLength > 0 Then
820826
dspName = Connect.TextBox2.Text
821827
End If
828+
'//////////////////////////////////////////////////
822829

823830
Connect.TextBox1.Text = ""
824831
Connect.TextBox1.Select()
825832

826833
Dim newAD As ActiveDirectory
827834

835+
'/////// Authentication //////////////////////////
828836
If Connect.promptAuth.Checked = False Then
829837
c.SetText(addr, True)
838+
'Create AD object, connect
830839
newAD = New ActiveDirectory(addr, Me, dspName)
831840
Else
832841
c.SetText("Waiting for authentication")
@@ -845,15 +854,17 @@ Public Class Form1
845854

846855
c.SetText(addr, True)
847856

857+
'Create AD object, connect with credentials
848858
newAD = New ActiveDirectory(addr, cred.Username, cred.Password, Me, dspName)
849859

850860
cred.Username = ""
851861
cred.Password = ""
852862
End If
863+
'//////////////////////////////////////////////////
853864

854865
While newAD.isLoading()
855866

856-
If newAD.conErr Then 'An error ocurred
867+
If newAD.conErr Then 'An error occurred
857868
c.Close()
858869

859870
Dim result As Integer
@@ -871,7 +882,7 @@ Public Class Form1
871882
Return
872883
End If
873884

874-
Await Task.Delay(600)
885+
Await Task.Delay(100)
875886

876887
If c.Cancel Then 'The user cancelled the process
877888
c.Close()
@@ -882,7 +893,7 @@ Public Class Form1
882893

883894
c.Close()
884895

885-
If Not newAD.testConnection Then
896+
If Not newAD.testConnection() Then
886897
Dim result As Integer
887898

888899
TASKDIALOG.TaskDialog(Handle, nullptr, "Connection error", "Could not connect to computer", "There was an error whilst connecting to " & addr & "." & vbCrLf &
@@ -921,7 +932,7 @@ Public Class Form1
921932
End If
922933
Dim result As Integer
923934

924-
TASKDIALOG.TaskDialog(Handle, nullptr, "Unkown error", "Could not connect to computer", "An unkown error ocurred whilst connecting to the computer." & vbCrLf &
935+
TASKDIALOG.TaskDialog(Handle, nullptr, "Unkown error", "Could not connect to computer", "An unkown error occurred whilst connecting to the computer." & vbCrLf &
925936
ex.Message.Replace(vbNewLine, ""), TASKDIALOG_COMMON_BUTTON_FLAGS.TDCBF_RETRY_BUTTON Or TASKDIALOG_COMMON_BUTTON_FLAGS.TDCBF_CLOSE_BUTTON, TD_ERROR_ICON, result)
926937

927938
If result = IDRETRY Then

lusrmgr/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' übernehmen, indem Sie "*" eingeben:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("1.5.0.0")>
35-
<Assembly: AssemblyFileVersion("1.5.0.0")>
34+
<Assembly: AssemblyVersion("1.5.1.0")>
35+
<Assembly: AssemblyFileVersion("1.5.1.0")>

lusrmgr/bin/Release/lusrmgr.exe

1.5 KB
Binary file not shown.

lusrmgr/lusrmgr.vbproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@
320320
</EmbeddedResource>
321321
<EmbeddedResource Include="Auth.resx">
322322
<DependentUpon>Auth.vb</DependentUpon>
323+
<SubType>Designer</SubType>
323324
</EmbeddedResource>
324325
<EmbeddedResource Include="ChangePw.resx">
325326
<DependentUpon>ChangePw.vb</DependentUpon>

lusrmgr/obj/Debug/lusrmgr.exe

1.5 KB
Binary file not shown.
294 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)