Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
akruhler authored Feb 13, 2021
1 parent 86574f0 commit e0345cd
Show file tree
Hide file tree
Showing 33 changed files with 704 additions and 420 deletions.
4 changes: 2 additions & 2 deletions lusrmgr/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("1.6.2.0")>
<Assembly: AssemblyFileVersion("1.6.2.0")>
<Assembly: AssemblyVersion("1.6.3.0")>
<Assembly: AssemblyFileVersion("1.6.3.0")>
10 changes: 0 additions & 10 deletions lusrmgr/My Project/Resources.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 0 additions & 37 deletions lusrmgr/My Project/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -476,43 +476,6 @@
SVJ4pQlss8a8FF295AoD8tS1yLxUtbQDsc7T1tNU18DidZYFLuGT8MdZwYRYbQcS6NvPV9UgW1mDdEWl
QE5rPtWx4ykyRnWYOPo3ks6XGHKVVUKQVRpFrqylN1KLjOJyGeN/1GrsIeIre8jB4lJPp108kpgsyyqt
JkE19h04lJQiyyiie1t5YC21hYghfk22jqBmxn4C9Q+Y/mU/loIAAAAASUVORK5CYII=
</value>
</data>
<data name="Shield" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABwAAAAbCAYAAABvCO8sAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
wwAADsMBx2+oZAAAB1ZJREFUSEutlndYVGcWxkd6EQURMShdQAPDgqgrdTWYPOiKxpJs3GUfQRLWhIgM
IGIABQYVCaAoLEgTE0CKonTpMAgMbYYmIEXpnaHDjKLvfmT8Q3dTzMbf85zn/nHPed97z3fu913K72Hr
1q3Ukycdrrt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EiYensD8Q2sy/scwn/UZpjMOoDP+I7QVh6Cp
uXXJxsY2k5Rt5lf/n2zapLyT7nu5op5Vg2e1P6I9xxVtaafRknoSbek09JA/OGZ1He/UqdMZ4uLi21+X
/TFUVTdSz5xxu5ObW7DQ2tKE/t5O9PV0oP1JK1LupY0dPXr0Bkn7kJ/9/pC1trb+1t3d856H5/l8Gs25
wNGRlkjG34rcW81Pef8Ik1hFQuZ1SJFY/q18RyiU/wAEiY4+tOV/NAAAAABJRU5ErkJggg==
</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
Expand Down
Binary file modified lusrmgr/bin/Release/lusrmgr.exe
Binary file not shown.
101 changes: 82 additions & 19 deletions lusrmgr/src/ActiveDirectory.vb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Public Class ActiveDirectory
''' </summary>
''' <remarks></remarks>
Private Sub UpdateLists()
If Not mainF.ViewHandler.GetView() = ViewHandler_C.View.MachineRoot AndAlso mainF.ADHandler.currentAD().Equals(Me) Then
If Not mainF.ViewHandler.GetView() = ViewHandler_C.View.MachineRoot AndAlso mainF.ADHandler.currentAD Is Me Then
mainF.ViewHandler.RefreshMainList()
End If
mainF.ViewHandler.RefreshSearch()
Expand All @@ -73,14 +73,6 @@ Public Class ActiveDirectory
main.Close()
End Sub

Public Shadows Function Equals(obj As ActiveDirectory) As Boolean
If GetID() = obj.GetID() Then
Return True
Else
Return False
End If
End Function

#Region "Constructors"

Public Sub New(mainForm As MainForm)
Expand Down Expand Up @@ -146,6 +138,10 @@ Public Class ActiveDirectory
Return isLoading_
End Function

Public Function IsRemoteAD() As Boolean
Return mainF.ADHandler.localAD IsNot Me
End Function

Public Function ConnectionErrorOccurred() As Boolean
Return conErr
End Function
Expand Down Expand Up @@ -272,7 +268,11 @@ Public Class ActiveDirectory
End If
Return Nothing
Catch ex As Exception
ShowUnknownErr(parentWnd, ex.Message)
If ex.HResult = &H80070035 Then 'Network path not found error
TaskDialog(parentWnd, "Local users and groups", "Could not access computer", "The network path could not be found.", TASKDIALOG_COMMON_BUTTON_FLAGS.TDCBF_OK_BUTTON, TD_ERROR_ICON, 0, True)
Else
ShowUnknownErr(parentWnd, ex.Message)
End If
Return Nothing
End Try
End Function
Expand All @@ -294,7 +294,11 @@ Public Class ActiveDirectory
End If
Return Nothing
Catch ex As Exception
ShowUnknownErr(parentWnd, ex.Message)
If ex.HResult = &H80070035 Then 'Network path not found error
TaskDialog(parentWnd, "Local users and groups", "Could not access computer", "The network path could not be found.", TASKDIALOG_COMMON_BUTTON_FLAGS.TDCBF_OK_BUTTON, TD_ERROR_ICON, 0, True)
Else
ShowUnknownErr(parentWnd, ex.Message)
End If
Return Nothing
End Try
End Function
Expand All @@ -317,7 +321,7 @@ Public Class ActiveDirectory
''' Refreshes the user and group database.
''' </summary>
''' <remarks></remarks>
Public Sub RefreshDS()
Public Sub RefreshDS(Optional DoNotUpdateLists As Boolean = False)
GroupList.Clear()
UserList.Clear()

Expand Down Expand Up @@ -370,7 +374,7 @@ Public Class ActiveDirectory
Return
End If

UpdateLists()
If Not DoNotUpdateLists Then UpdateLists()
End Sub

#Region "Rename handlers"
Expand All @@ -390,18 +394,48 @@ Public Class ActiveDirectory
Dim dsuserp As DsEntry = FindUser(Name, parentWnd)
If dsuserp IsNot Nothing AndAlso newName <> dsuserp.Name Then
Try
dsuserp.Rename(newName)
dsuserp.CommitChanges()
'On the local machine, WMI is used for renaming because of the better performance it provides.
If Not IsRemoteAD() Then
Dim result As Integer = 0
Try
'For better performance, the WMI Win32_UserAccount class is used to invoke the rename method locally.
Dim wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\localhost\root\cimv2")
Dim accounts = wmi.ExecQuery("Select * from Win32_UserAccount Where Name = '" & Name & "'")
result = accounts.ItemIndex(0).Rename(newName)
Catch ex As Exception
Dim a = ex.GetType()
'Fallback to DirectoryServices
If Not Warnings.Exists(Function(w As ADWarning) As Boolean
Return w.Title = "WMI initialization failed"
End Function) Then
'Add a warning message if not previously done
Warnings.Add(New ADWarning("WMI initialization failed", "Failed to invoke WMI initialization during rename.", ex.Message))
mainF.ViewHandler.RefreshWarnings()
End If
dsuserp.Rename(newName)
dsuserp.CommitChanges()
End Try

If result <> SystemErrorCodes.SUCCESS Then
'Fallback to DirectoryServices to recieve further information about the error
dsuserp.Rename(newName)
dsuserp.CommitChanges()
End If
Else
dsuserp.Rename(newName)
dsuserp.CommitChanges()
End If

Dim fullName As String = UserList(Name)
UserList.Remove(Name)
UserList.Add(newName, fullName)
UpdateLists()

RefreshDS()
RaiseEvent OnRenameUser(Name, newName)
Return True
Catch ex As UnauthorizedAccessException
ShowPermissionDeniedErr(mainF.Handle)
ShowPermissionDeniedErr(mainF.Handle, IsRemoteAD())
Return False
Catch ex As Runtime.InteropServices.COMException
If ex.ErrorCode = COMErrorCodes.GROUP_NOT_FOUND_USER Then
Expand All @@ -425,17 +459,46 @@ Public Class ActiveDirectory
Dim dsgrp As DsEntry = FindGroup(Name, parentWnd)
If dsgrp IsNot Nothing AndAlso newName <> dsgrp.Name Then
Try
dsgrp.Rename(newName)
dsgrp.CommitChanges()
'On the local machine, WMI is used for renaming because of the better performance it provides.
If Not IsRemoteAD() Then
Dim result As Integer = 0
Try
'For better performance, the WMI Win32_Group class is used to invoke the rename method locally.
Dim wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\localhost\root\cimv2")
Dim groups = wmi.ExecQuery("Select * from Win32_Group Where Name = '" & Name & "'")
result = groups.ItemIndex(0).Rename(newName)
Catch ex As Exception
'Fallback to DirectoryServices
If Not Warnings.Exists(Function(w As ADWarning) As Boolean
Return w.Title = "WMI initialization failed"
End Function) Then
'Add a warning message if not previously done
Warnings.Add(New ADWarning("WMI initialization failed", "Failed to invoke WMI initialization during rename.", ex.Message))
mainF.ViewHandler.RefreshWarnings()
End If
dsgrp.Rename(newName)
dsgrp.CommitChanges()
End Try

If result <> SystemErrorCodes.SUCCESS Then
'Fallback to DirectoryServices to recieve further information about the error
dsgrp.Rename(newName)
dsgrp.CommitChanges()
End If
Else
dsgrp.Rename(newName)
dsgrp.CommitChanges()
End If

GroupList.Remove(Name)
GroupList.Add(newName)
UpdateLists()

RefreshDS()
RaiseEvent OnRenameGroup(Name, newName)
Return True
Catch ex As UnauthorizedAccessException
ShowPermissionDeniedErr(parentWnd)
ShowPermissionDeniedErr(parentWnd, IsRemoteAD())
Return False
Catch ex As Runtime.InteropServices.COMException
If ShowCOMErr(ex.ErrorCode, parentWnd, ex.Message, Name) = COMErrResult.REFRESH Then
Expand Down
2 changes: 1 addition & 1 deletion lusrmgr/src/Dialogs/About.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lusrmgr/src/Dialogs/AddToGroup.vb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Public Class AddToGroup
dstListView.Items.Add(item.Clone())

Catch ex As UnauthorizedAccessException
ShowPermissionDeniedErr(Handle)
ShowPermissionDeniedErr(Handle, AD.IsRemoteAD())
Return
Catch ex As Runtime.InteropServices.COMException
If ShowCOMErr(ex.ErrorCode, Handle, ex.Message, item.Text) <> COMErrResult.LOOP_CONTINUE Then
Expand All @@ -128,7 +128,7 @@ Public Class AddToGroup
dstListView.Items.Add(group.Name, 1)

Catch ex As UnauthorizedAccessException
ShowPermissionDeniedErr(Handle)
ShowPermissionDeniedErr(Handle, AD.IsRemoteAD())
Return
Catch ex As Runtime.InteropServices.COMException
If ShowCOMErr(ex.ErrorCode, Handle, ex.Message, item.Text) <> COMErrResult.LOOP_CONTINUE Then
Expand Down
15 changes: 15 additions & 0 deletions lusrmgr/src/Dialogs/Search.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e0345cd

Please sign in to comment.