From 37efa65f77e71b7e6b17fc89249823b959673393 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Sun, 1 Nov 2026 22:01:39 +0100 Subject: [PATCH 001/100] Refactor: Remote Desktop: Shared control for the credentials of profiles and groups (W1) The credentials (use credentials, username, domain, password, warning if the profile file is not encrypted) were written out in the profile and the group dialog, and their validation was repeated in three MultiDataTriggers each for the Save button and the error icon of the tab (ElementName bindings to the text boxes). WindowsCredentialsControl / WindowsCredentialsViewModel (like the SNMP credentials control) hold them, with HasError (same rules as the validators) and the values to save (empty if not used). Preparation for the Windows credentials of the IP Scanner. No behaviour change, no change of the profile file. Co-Authored-By: Claude Opus 5.5 --- .../Controls/WindowsCredentialsControl.xaml | 94 ++++++ .../WindowsCredentialsControl.xaml.cs | 13 + Source/NETworkManager/ProfileDialogManager.cs | 32 +- .../ViewModels/GroupViewModel.cs | 84 +---- .../ViewModels/ProfileViewModel.cs | 79 +---- .../ViewModels/WindowsCredentialsViewModel.cs | 132 ++++++++ .../Views/GroupChildWindow.xaml | 287 +++++------------- .../Views/ProfileChildWindow.xaml | 287 +++++------------- 8 files changed, 413 insertions(+), 595 deletions(-) create mode 100644 Source/NETworkManager/Controls/WindowsCredentialsControl.xaml create mode 100644 Source/NETworkManager/Controls/WindowsCredentialsControl.xaml.cs create mode 100644 Source/NETworkManager/ViewModels/WindowsCredentialsViewModel.cs diff --git a/Source/NETworkManager/Controls/WindowsCredentialsControl.xaml b/Source/NETworkManager/Controls/WindowsCredentialsControl.xaml new file mode 100644 index 0000000000..ae532f8842 --- /dev/null +++ b/Source/NETworkManager/Controls/WindowsCredentialsControl.xaml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - @@ -1097,11 +994,11 @@ - - - - @@ -1195,10 +1092,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2379,11 +2269,11 @@ - - - - @@ -2477,10 +2367,10 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -1316,6 +1415,8 @@ + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -1627,7 +1627,7 @@ - + @@ -1754,8 +1754,194 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1939,7 +2125,7 @@ - + @@ -2025,192 +2211,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Website/docs/application/ip-scanner.md b/Website/docs/application/ip-scanner.md index e02569ecc7..b3804dbdea 100644 --- a/Website/docs/application/ip-scanner.md +++ b/Website/docs/application/ip-scanner.md @@ -66,7 +66,7 @@ with link-local addresses (`169.254.x.x`) given lower priority. ::: -The **Options** button next to **Scan** opens a menu to turn the most used [settings](#settings) on or off without opening the settings: [Ping hosts](#ping-hosts), [Resolve hostname](#resolve-hostname), [Scan ports](#scan-ports), [Scan for NetBIOS](#scan-for-netbios), [Find hosts in the local subnet](#find-hosts-in-the-local-subnet), [Resolve MAC address and vendor](#resolve-mac-address-and-vendor), [Resolve mDNS hostname](#resolve-mdns-hostname), [Read web pages](#read-web-pages) (only with the port scan), [Read the SNMP system information](#read-the-snmp-system-information), [Read Windows host information](#read-windows-host-information), [Show unreachable IP addresses and ports](#show-unreachable-ip-addresses-and-ports) and [Expand host view](#expand-host-view). **Open settings...** opens the IP Scanner settings. The menu stays open to change several options and is disabled while a scan is running. A tab opened with a profile whose profile or group overrides the [SNMP version and credentials](#snmp-version-and-credentials) shows it below the SNMP option (e.g. `SNMP version and credentials of "Site A"`), the same for the [Windows credentials](#windows-credentials) below the Windows option (e.g. `Windows credentials of "Site A" (CORP\admin)`). +The **Options** button next to **Scan** opens a menu to turn the most used [settings](#settings) on or off without opening the settings: [Ping hosts](#ping-hosts), [Resolve hostname](#resolve-hostname), [Scan ports](#scan-ports), [Read Windows host information](#read-windows-host-information), [Scan for NetBIOS](#scan-for-netbios), [Find hosts in the local subnet](#find-hosts-in-the-local-subnet), [Resolve MAC address and vendor](#resolve-mac-address-and-vendor), [Resolve mDNS hostname](#resolve-mdns-hostname), [Read web pages](#read-web-pages) (only with the port scan), [Read the SNMP system information](#read-the-snmp-system-information), [Show unreachable IP addresses and ports](#show-unreachable-ip-addresses-and-ports) and [Expand host view](#expand-host-view). **Open settings...** opens the IP Scanner settings. The menu stays open to change several options and is disabled while a scan is running. A tab opened with a profile whose profile or group overrides the [SNMP version and credentials](#snmp-version-and-credentials) shows it below the SNMP option (e.g. `SNMP version and credentials of "Site A"`), the same for the [Windows credentials](#windows-credentials) below the Windows option (e.g. `Windows credentials of "Site A" (CORP\admin)`). The menu changes the settings: they apply to all tabs and are shown in the settings. Changes apply to the next scan (**Expand host view** immediately), like a change in the settings. @@ -85,7 +85,7 @@ Right-clicking a result allows forwarding device information to another tool (e. | **Wake on LAN** | Sends a magic packet to the MAC address of the host with [Wake on LAN](./wake-on-lan) (only with a MAC address) | | **Custom commands** | Executes a [custom command](#custom-commands) for the host | | **Add profile...** | Creates a new profile with the host (IP address), the hostname as name and the MAC address for Wake on LAN | -| **Copy** | Copies the selected information to the clipboard (values only when the probe / lookup is finished); with the optional requests also **mDNS hostname**, **Web** > **Title** / **URL** / **Server** and **SNMP** > **Name** / **Description** / **Location** and **Windows** > **Operating system** / **Domain** / **Logged-on users** | +| **Copy** | Copies the selected information to the clipboard (values only when the probe / lookup is finished); with the optional requests also **mDNS hostname**, **Windows** > **Operating system** / **Domain** / **Logged-on users**, **Web** > **Title** / **URL** / **Server** and **SNMP** > **Name** / **Description** / **Location** | | **Export...** | Exports the selected or all results to a file | A NetBIOS or mDNS name (shown as hostname if there is no DNS hostname) is not passed to other tools, because it may not be resolvable via DNS - the IP address is used instead. **DNS lookup...** / **RDAP...** > **Hostname** are only available with a DNS hostname. In [custom commands](#custom-commands), `{{Hostname}}` is the shown hostname (DNS, mDNS or NetBIOS). @@ -125,12 +125,12 @@ The columns are shown according to the settings the scan was started with, setti | **Time** | Round trip time of the ping reply | | **OS (guess)** | Operating system guessed from the TTL of the ping reply, see [Guess the operating system from the TTL](#guess-the-operating-system-from-the-ttl) | | **Port status** | Status icon (a port is open), the tooltip shows the open ports with their service (e.g. `Open: 22 (ssh), 443 (https)`, the first 10) | -| **Web** | Title of the web page, otherwise the realm of a login prompt, the `Server` header or the target of a redirect; the URL in the tooltip, see [Read web pages](#read-web-pages) | -| **SNMP name** | `sysName`, see [Read the SNMP system information](#read-the-snmp-system-information) | | **Windows** | Windows version (e.g. `Windows 11 25H2`), the version number in the tooltip, see [Read Windows host information](#read-windows-host-information) | | **Domain** | Domain (DNS name) or workgroup of the Windows host | | **Time offset** | Time of the host minus the local time (e.g. `+1.2 s`, `-3 min 5 s`), highlighted above 5 minutes (the Kerberos limit, the logon in a domain fails) | | **Logged-on users** | Logged-on users (needs admin rights on the host), one per line in the tooltip or why they could not be read (e.g. `Access is denied.`) | +| **Web** | Title of the web page, otherwise the realm of a login prompt, the `Server` header or the target of a redirect; the URL in the tooltip, see [Read web pages](#read-web-pages) | +| **SNMP name** | `sysName`, see [Read the SNMP system information](#read-the-snmp-system-information) | | **NetBIOS reachable** | Status icon, the tooltip shows the computer name and the workgroup / domain (e.g. `Yes (PC01, WORKGROUP)`) | | **MAC address** / **Vendor** | From the neighbor table (ARP / NDP), the NetBIOS answer as fallback | @@ -168,9 +168,9 @@ The repetition stops when a scan is canceled, the input is changed (also while a Expand a row with the button in front of it to see all values of the host, or enable [Expand host view](#expand-host-view) to expand all hosts: -| Ping details | Ports | Web | NetBIOS | Windows | -| ------------ | ----- | --- | ------- | ------- | -| **Hostnames** | (ports) | (web) | **SNMP** | (Windows) | +| Ping details | Ports | Windows | Web | NetBIOS | +| ------------ | ----- | ------- | --- | ------- | +| **Hostnames** | (ports) | (Windows) | (web) | **SNMP** | | Section | Content | | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | @@ -428,6 +428,54 @@ In a local network (LAN), `1` is enough. On an unreliable network (e.g. Wi-Fi, V ::: +### Read Windows host information + +Read the Windows host information of every reachable host over SMB (TCP port `445`). With [Scan ports](#scan-ports) enabled and port `445` in its [ports](#ports), only hosts with port `445` open are asked, otherwise every found host (a host without SMB is finished after the SMB request). + +Two steps, the second only if the host answered the first: + +| Step | Credentials | Values | +| ---- | ----------- | ------ | +| SMB / NTLM negotiation | None (no logon, no failed logon on the host) | Operating system and build (e.g. `Windows 11 25H2`, `10.0.26200`), computer name, domain, time offset to the local clock, SMB version and signing | +| NetApi (RPC over SMB) | User running NETworkManager, or the [Windows credentials](#windows-credentials) of the profile / group the tab was opened with | Role (workstation, server, domain controller), description, workgroup; with admin rights on the host also the logged-on users and, if the Remote Registry service runs, the patch level, display version and edition (e.g. `Pro`, `10.0.26200.6584`) | + +The NetApi requests connect to the DNS hostname of the host if it is the full DNS name the host sends itself in the NTLM negotiation (Kerberos), otherwise to the IP address (NTLM, e.g. a computer in a workgroup). Errors (e.g. `Access is denied.`, wrong password) are shown in the row details instead of the values. + +**Type:** `Boolean` + +**Default:** `Disabled` + +:::note + +Windows 10 / 11 and Windows Server 2016 and later all report the version `10.0`, the build tells them apart. Some builds are shared by a client and a server version (e.g. `26100`: Windows 11 24H2 / Server 2025), the role decides if it could be read. Hosts that only allow Kerberos (NTLM disabled) don't send the NTLM values; Samba and NAS devices answer with their own values (no Windows version). + +::: + +:::note + +With the [Windows credentials](#windows-credentials) of a profile / group, a wrong password must not lock the account (every host in a domain makes the domain controller count a failed logon). The credentials are checked on one host first, the other hosts wait: + +- Accepted (also `Access is denied.`: logged on, but without rights): all hosts are asked. +- Logon failure on a host in the domain of the credentials (or the third logon failure on hosts of other domains): the credentials are rejected. The other hosts are not tried (`Not tried: ...` in the row details), a message is shown and the tab doesn't use them for the next scans (also not for **Automatically scan every** and **Rescan**) - open a new tab after correcting them. + +Computers in a workgroup and local accounts (`.\admin`) are not part of this check: a logon failure there only affects the host (e.g. a Windows PC that is not in the domain shows the error in its row, the other hosts are not affected). The user running NETworkManager is not checked (no stored password). + +::: + +:::note + +The NetApi requests need the firewall rules **File and Printer Sharing (SMB-In)** on the host, the logged-on users admin rights (e.g. a domain admin or the local administrator), the patch level also the **Remote Registry** service (disabled by default on Windows clients). + +::: + +### Timeout (ms) + +Timeout in milliseconds of the SMB request and of the NetApi requests of a host (each). NetApi requests that take longer are shown as timed out; they keep running in the background until Windows ends them (max. 16 at the same time, for all tabs and repeated scans). + +**Type:** `Integer` [Min `500`, Max `30000`] + +**Default:** `5000` + ### Scan for NetBIOS Scan each IP address for NetBIOS information. @@ -559,7 +607,7 @@ Read the name, description and location (`sysName`, `sysDescr`, `sysLocation`) o A host with another community usually doesn't answer at all (no value after the timeout); an answer with an error (e.g. `noSuchName` of SNMP v1) still counts as up. The request is sent to every IP address of the range, also unused ones. Many intrusion detection systems report requests with common communities like `public`. -SNMP v3 needs credentials, so it is only available with the [SNMP version and credentials](#snmp-version-and-credentials) of a profile or group (not in the settings, the settings file is not encrypted). A discovery request is sent first: every SNMP v3 agent answers it, also without valid credentials, so the host is found anyway. Then the `GET` request with the user; wrong credentials are answered with an error, shown in the row details (**SNMP**) and exported as `SNMPError` (e.g. `UnknownUserName`, `AuthenticationFailed`). Each of the two requests waits up to the [timeout](#timeout-ms-5). +SNMP v3 needs credentials, so it is only available with the [SNMP version and credentials](#snmp-version-and-credentials) of a profile or group (not in the settings, the settings file is not encrypted). A discovery request is sent first: every SNMP v3 agent answers it, also without valid credentials, so the host is found anyway. Then the `GET` request with the user; wrong credentials are answered with an error, shown in the row details (**SNMP**) and exported as `SNMPError` (e.g. `UnknownUserName`, `AuthenticationFailed`). Each of the two requests waits up to the [timeout](#timeout-ms-6). ::: @@ -598,54 +646,6 @@ Timeout in milliseconds after which an SNMP request is considered lost. **Default:** `2000` -### Read Windows host information - -Read the Windows host information of every reachable host over SMB (TCP port `445`). With [Scan ports](#scan-ports) enabled and port `445` in its [ports](#ports), only hosts with port `445` open are asked, otherwise every found host (a host without SMB is finished after the SMB request). - -Two steps, the second only if the host answered the first: - -| Step | Credentials | Values | -| ---- | ----------- | ------ | -| SMB / NTLM negotiation | None (no logon, no failed logon on the host) | Operating system and build (e.g. `Windows 11 25H2`, `10.0.26200`), computer name, domain, time offset to the local clock, SMB version and signing | -| NetApi (RPC over SMB) | User running NETworkManager, or the [Windows credentials](#windows-credentials) of the profile / group the tab was opened with | Role (workstation, server, domain controller), description, workgroup; with admin rights on the host also the logged-on users and, if the Remote Registry service runs, the patch level, display version and edition (e.g. `Pro`, `10.0.26200.6584`) | - -The NetApi requests connect to the DNS hostname of the host if it is the full DNS name the host sends itself in the NTLM negotiation (Kerberos), otherwise to the IP address (NTLM, e.g. a computer in a workgroup). Errors (e.g. `Access is denied.`, wrong password) are shown in the row details instead of the values. - -**Type:** `Boolean` - -**Default:** `Disabled` - -:::note - -Windows 10 / 11 and Windows Server 2016 and later all report the version `10.0`, the build tells them apart. Some builds are shared by a client and a server version (e.g. `26100`: Windows 11 24H2 / Server 2025), the role decides if it could be read. Hosts that only allow Kerberos (NTLM disabled) don't send the NTLM values; Samba and NAS devices answer with their own values (no Windows version). - -::: - -:::note - -With the [Windows credentials](#windows-credentials) of a profile / group, a wrong password must not lock the account (every host in a domain makes the domain controller count a failed logon). The credentials are checked on one host first, the other hosts wait: - -- Accepted (also `Access is denied.`: logged on, but without rights): all hosts are asked. -- Logon failure on a host in the domain of the credentials (or the third logon failure on hosts of other domains): the credentials are rejected. The other hosts are not tried (`Not tried: ...` in the row details), a message is shown and the tab doesn't use them for the next scans (also not for **Automatically scan every** and **Rescan**) - open a new tab after correcting them. - -Computers in a workgroup and local accounts (`.\admin`) are not part of this check: a logon failure there only affects the host (e.g. a Windows PC that is not in the domain shows the error in its row, the other hosts are not affected). The user running NETworkManager is not checked (no stored password). - -::: - -:::note - -The NetApi requests need the firewall rules **File and Printer Sharing (SMB-In)** on the host, the logged-on users admin rights (e.g. a domain admin or the local administrator), the patch level also the **Remote Registry** service (disabled by default on Windows clients). - -::: - -### Timeout (ms) - -Timeout in milliseconds of the SMB request and of the NetApi requests of a host (each). NetApi requests that take longer are shown as timed out; they keep running in the background until Windows ends them (max. 16 at the same time, for all tabs and repeated scans). - -**Type:** `Integer` [Min `500`, Max `30000`] - -**Default:** `5000` - ### Show notification popup on changes Show a notification popup in the bottom-right corner of the primary screen when a [repeated scan](#repeat-the-scan) found changes since the previous scan (see [Changes since the last scan](#changes-since-the-last-scan); only new hosts like a host that is up, a gone host or a changed MAC address like a host that is down). One notification per scan: up to three changes, one per line with the IP address (and hostname) and the change in its color (e.g. `10.0.0.5 (server) · New`, green for new, red for gone, orange for a changed MAC address), otherwise one line per counter (e.g. `5 New`, `2 Gone`). Not for a scan that was started manually. The header shows the tool, the title the scanned input; the status icon is green for only new hosts, red for only gone hosts, half green / half red for both, orange for a changed MAC address. A click opens the tab of the scan. From 98e33826412eba0b49b89d131d550f483ddb1582 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Sun, 1 Nov 2026 23:15:14 +0100 Subject: [PATCH 017/100] Fix: IP Scanner: User of the Windows credentials appended outside the translation (L1) The options line 'Windows credentials of "Site A" (CORP\admin)' appended the user in the code, so a translation couldn't change its position. The user is a placeholder of the string now. Co-Authored-By: Claude Opus 5.5 --- .../NETworkManager.Localization/Resources/Strings.Designer.cs | 2 +- Source/NETworkManager.Localization/Resources/Strings.resx | 4 ++-- Source/NETworkManager/ViewModels/IPScannerViewModel.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs index c70ae08385..a6143592c7 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs +++ b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs @@ -15434,7 +15434,7 @@ public static string Windows { } /// - /// Looks up a localized string similar to Windows credentials of "{0}". + /// Looks up a localized string similar to Windows credentials of "{0}" ({1}). /// public static string WindowsCredentialsOfX { get { diff --git a/Source/NETworkManager.Localization/Resources/Strings.resx b/Source/NETworkManager.Localization/Resources/Strings.resx index 5470ebaa17..4ae7ce5b5d 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.resx @@ -5364,8 +5364,8 @@ Do you want to start the scan? Read the Windows host information of every reachable host over SMB (TCP port 445): with the port scan and port 445 in its list only for hosts with port 445 open, otherwise for every found host. Without credentials (SMB / NTLM negotiation, no logon): operating system and build, computer name, domain and the time offset. With credentials (NetApi): role (workstation, server, domain controller), description and workgroup; logged-on users and the patch level (remote registry) need admin rights on the host. The user running NETworkManager is used, or the Windows credentials of the profile / group the tab was opened with. - Windows credentials of "{0}" - IP Scanner: the tab uses the Windows credentials of a profile or group, {0} is its name. + Windows credentials of "{0}" ({1}) + IP Scanner: the tab uses the Windows credentials of a profile or group, {0} is its name, {1} the user (e.g. CORP\admin). Operating system diff --git a/Source/NETworkManager/ViewModels/IPScannerViewModel.cs b/Source/NETworkManager/ViewModels/IPScannerViewModel.cs index 136ad525f6..d47c04ab86 100644 --- a/Source/NETworkManager/ViewModels/IPScannerViewModel.cs +++ b/Source/NETworkManager/ViewModels/IPScannerViewModel.cs @@ -576,7 +576,7 @@ public IPScannerViewModel(Guid tabId, string hostOrIPRange, bool start = true, _windowsCredentials = windowsCredentials; WindowsCredentialsInfo = windowsCredentials == null ? null - : $"{string.Format(Strings.WindowsCredentialsOfX, windowsCredentialsSource)} ({windowsCredentials})"; + : string.Format(Strings.WindowsCredentialsOfX, windowsCredentialsSource, windowsCredentials); // Repeat of the scan (before the input is set, see its setter): not while a scan or rescan is running, or a // manual scan waits for its confirmation From ede07479b4ab4e226f12442194dc2502a22f2ba6 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Sun, 1 Nov 2026 23:18:19 +0100 Subject: [PATCH 018/100] Feature: IP Scanner: Windows credentials of a tab and Scan as... (S2) Options > Windows credentials... sets the Windows credentials of the tab (WindowsCredentialsChildWindow with the shared credentials control, not saved, discarded with the tab): they replace the ones of the profile / group, "Use credentials" off uses the user running the application. Works also for a tab without a profile (no Windows credentials in the settings). They are used for the following scans, Automatically scan every and Rescan (a rescan uses the current credentials of the tab, not the ones of the last scan); credentials that were rejected are used again after they were set. The options show 'Windows credentials of this tab (CORP\admin)'. Scan as... in the context menu of a profile asks for the credentials (the ones of the profile / group as default) and scans the profile with them in a new tab, like Connect as... of the Remote Desktop. Co-Authored-By: Claude Opus 5.5 --- .../Resources/Strings.Designer.cs | 56 +++++++++++++- .../Resources/Strings.resx | 23 +++++- .../ViewModels/IPScannerHostViewModel.cs | 35 +++++++++ .../ViewModels/IPScannerViewModel.cs | 73 ++++++++++++++++--- .../WindowsCredentialsChildWindowViewModel.cs | 51 +++++++++++++ .../Views/IPScannerHostView.xaml | 11 +++ .../NETworkManager/Views/IPScannerView.xaml | 5 +- .../Views/WindowsCredentialsChildWindow.xaml | 46 ++++++++++++ .../WindowsCredentialsChildWindow.xaml.cs | 56 ++++++++++++++ Website/docs/application/ip-scanner.md | 6 +- Website/docs/changelog/next-release.md | 2 +- 11 files changed, 347 insertions(+), 17 deletions(-) create mode 100644 Source/NETworkManager/ViewModels/WindowsCredentialsChildWindowViewModel.cs create mode 100644 Source/NETworkManager/Views/WindowsCredentialsChildWindow.xaml create mode 100644 Source/NETworkManager/Views/WindowsCredentialsChildWindow.xaml.cs diff --git a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs index a6143592c7..e7a762e6e8 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs +++ b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs @@ -6320,6 +6320,15 @@ public static string HelpMessage_UseCustomThemes { } } + /// + /// Looks up a localized string similar to Windows credentials for the Windows host information of this tab (also for repeated scans and Rescan), replacing the ones of the profile / group. They are not saved and are discarded when the tab is closed. Without credentials, the user running NETworkManager is used.. + /// + public static string HelpMessage_WindowsCredentialsOfTheTab { + get { + return ResourceManager.GetString("HelpMessage_WindowsCredentialsOfTheTab", resourceCulture); + } + } + /// /// Looks up a localized string similar to Help translate the project on Transifex.. /// @@ -12637,6 +12646,24 @@ public static string Scan { } } + /// + /// Looks up a localized string similar to Scan as. + /// + public static string ScanAs { + get { + return ResourceManager.GetString("ScanAs", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Scan as.... + /// + public static string ScanAsDots { + get { + return ResourceManager.GetString("ScanAsDots", resourceCulture); + } + } + /// /// Looks up a localized string similar to Scan for NetBIOS. /// @@ -15433,6 +15460,33 @@ public static string Windows { } } + /// + /// Looks up a localized string similar to Windows credentials. + /// + public static string WindowsCredentials { + get { + return ResourceManager.GetString("WindowsCredentials", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Windows credentials.... + /// + public static string WindowsCredentialsDots { + get { + return ResourceManager.GetString("WindowsCredentialsDots", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Windows credentials of this tab ({0}). + /// + public static string WindowsCredentialsOfThisTabX { + get { + return ResourceManager.GetString("WindowsCredentialsOfThisTabX", resourceCulture); + } + } + /// /// Looks up a localized string similar to Windows credentials of "{0}" ({1}). /// @@ -15461,7 +15515,7 @@ public static string WindowsFirewallSettings { } /// - /// Looks up a localized string similar to The logon with the Windows credentials "{0}" failed (wrong username or password?). To protect the account from being locked out, they are not used for the other hosts and the next scans of this tab. Check the credentials of the profile / group and open a new tab.. + /// Looks up a localized string similar to The logon with the Windows credentials "{0}" failed (wrong username or password?). To protect the account from being locked out, they are not used for the other hosts and the next scans of this tab. Set them again with Windows credentials... in the options, or open a new tab after correcting the profile / group.. /// public static string WindowsLogonFailedMessage { get { diff --git a/Source/NETworkManager.Localization/Resources/Strings.resx b/Source/NETworkManager.Localization/Resources/Strings.resx index 4ae7ce5b5d..e3b48d438a 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.resx @@ -5403,10 +5403,31 @@ Do you want to start the scan? Reading Windows host information is disabled! - The logon with the Windows credentials "{0}" failed (wrong username or password?). To protect the account from being locked out, they are not used for the other hosts and the next scans of this tab. Check the credentials of the profile / group and open a new tab. + The logon with the Windows credentials "{0}" failed (wrong username or password?). To protect the account from being locked out, they are not used for the other hosts and the next scans of this tab. Set them again with Windows credentials... in the options, or open a new tab after correcting the profile / group. {0} is the user (e.g. CORP\admin) Not tried: the Windows credentials were rejected on another host (protection against an account lockout). + + Windows credentials + + + Windows credentials... + + + Scan as... + IP Scanner: scan a profile with other Windows credentials + + + Windows credentials of this tab ({0}) + IP Scanner: the tab uses Windows credentials entered for it (not saved), {0} is the user (e.g. CORP\admin). + + + Windows credentials for the Windows host information of this tab (also for repeated scans and Rescan), replacing the ones of the profile / group. They are not saved and are discarded when the tab is closed. Without credentials, the user running NETworkManager is used. + + + Scan as + IP Scanner: title of the dialog to scan a profile with other Windows credentials + \ No newline at end of file diff --git a/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs b/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs index 128a25ec71..8a48866ff5 100644 --- a/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs @@ -8,6 +8,8 @@ using NETworkManager.Views; using System; using System.Collections.ObjectModel; +using System.Threading.Tasks; +using System.Windows; using System.Windows.Input; namespace NETworkManager.ViewModels; @@ -127,6 +129,39 @@ private void ScanProfileAction() AddTab(SelectedProfile); } + /// + /// Gets the command to scan the selected profile with other Windows credentials (like Connect as... of Remote + /// Desktop). + /// + public ICommand ScanProfileAsCommand => new RelayCommand(_ => ScanProfileAsAction(), ScanProfile_CanExecute); + + private void ScanProfileAsAction() + { + _ = ScanProfileAs(); + } + + /// + /// Asks for the Windows credentials (the ones of the profile / group as default) and scans the selected profile with + /// them in a new tab. They are only used by this tab, the profile is not changed. + /// + private async Task ScanProfileAs() + { + var profile = SelectedProfile; + + var (isOK, windowsCredentials) = await WindowsCredentialsChildWindow.ShowAsync(Application.Current.MainWindow, + Strings.ScanAs, NETworkManager.Profiles.Application.IPScanner.GetWindowsCredentials(profile)); + + if (!isOK) + return; + + // SNMP version and credentials of the profile, otherwise of its group, otherwise the settings (null) + var snmpCredentials = NETworkManager.Profiles.Application.IPScanner.GetSNMPCredentials(profile); + + // No source: the credentials were entered for the tab + AddTab(profile.IPScanner_HostOrIPRange, true, snmpCredentials, + profile.IPScanner_OverrideSNMP ? profile.Name : profile.Group, windowsCredentials); + } + /// /// Gets the callback for closing a tab item. /// diff --git a/Source/NETworkManager/ViewModels/IPScannerViewModel.cs b/Source/NETworkManager/ViewModels/IPScannerViewModel.cs index d47c04ab86..6eea211c87 100644 --- a/Source/NETworkManager/ViewModels/IPScannerViewModel.cs +++ b/Source/NETworkManager/ViewModels/IPScannerViewModel.cs @@ -52,9 +52,9 @@ public class IPScannerViewModel : ViewModelBase, IProfileManagerMinimal // SNMP request of a scan, see GetProfileSNMPCredentials), null for the ones of the settings private readonly SNMPSecureCredentials _snmpCredentials; - // Windows credentials of the profile / group the tab was opened with (password protected, see WindowsLogon), null - // for the user running the application - private readonly WindowsCredentials _windowsCredentials; + // Windows credentials of the profile / group the tab was opened with or entered for the tab (password protected, + // see WindowsLogon), null for the user running the application + private WindowsCredentials _windowsCredentials; // The Windows credentials were rejected in a scan of the tab (wrong username or password): not used for the next // scans, so a repeated scan doesn't lock the account (see WindowsLogonGate) @@ -130,10 +130,21 @@ public class IPScannerViewModel : ViewModelBase, IProfileManagerMinimal public string SNMPCredentialsInfo { get; } /// - /// Profile / group whose Windows credentials the tab uses (shown in the options, e.g. 'Windows credentials of - /// "Site A" (CORP\admin)'), null if the user running the application is used. + /// Windows credentials the tab uses (shown in the options, e.g. 'Windows credentials of "Site A" (CORP\admin)' or + /// 'Windows credentials of this tab (CORP\admin)'), null if the user running the application is used. /// - public string WindowsCredentialsInfo { get; } + public string WindowsCredentialsInfo + { + get; + private set + { + if (value == field) + return; + + field = value; + OnPropertyChanged(); + } + } /// /// Gets or sets the host or IP range to scan. @@ -562,7 +573,9 @@ private set /// /// Windows credentials of the profile / group the tab was opened with, null for the user running the application. /// - /// Name of the profile / group of . + /// + /// Name of the profile / group of , null if they were entered for the tab. + /// public IPScannerViewModel(Guid tabId, string hostOrIPRange, bool start = true, SNMPSecureCredentials snmpCredentials = null, string snmpCredentialsSource = null, WindowsCredentials windowsCredentials = null, string windowsCredentialsSource = null) @@ -576,7 +589,9 @@ public IPScannerViewModel(Guid tabId, string hostOrIPRange, bool start = true, _windowsCredentials = windowsCredentials; WindowsCredentialsInfo = windowsCredentials == null ? null - : string.Format(Strings.WindowsCredentialsOfX, windowsCredentialsSource, windowsCredentials); + : windowsCredentialsSource == null + ? string.Format(Strings.WindowsCredentialsOfThisTabX, windowsCredentials) + : string.Format(Strings.WindowsCredentialsOfX, windowsCredentialsSource, windowsCredentials); // Repeat of the scan (before the input is set, see its setter): not while a scan or rescan is running, or a // manual scan waits for its confirmation @@ -748,6 +763,43 @@ private void UseAllLocalSubnetsAction() /// public ICommand OpenSettingsCommand => new RelayCommand(_ => NavigationManager.OpenSettings()); + /// + /// Gets the command to enter the Windows credentials of the tab (not saved), see + /// . + /// + public ICommand SetWindowsCredentialsCommand => + new RelayCommand(_ => SetWindowsCredentialsAction(), _ => !IsRunning); + + private void SetWindowsCredentialsAction() + { + _ = SetWindowsCredentials(); + } + + /// + /// Shows the dialog for the Windows credentials of the tab. New credentials replace the ones of the profile / group + /// and are used again, also if the old ones were rejected. + /// + private async Task SetWindowsCredentials() + { + var window = Application.Current.Windows.OfType().FirstOrDefault(x => x.IsActive); + + if (window == null) + return; + + var (isOK, credentials) = + await WindowsCredentialsChildWindow.ShowAsync(window, Strings.WindowsCredentials, _windowsCredentials); + + if (!isOK) + return; + + _windowsCredentials = credentials; + _isWindowsCredentialsRejected = false; + + WindowsCredentialsInfo = credentials == null + ? null + : string.Format(Strings.WindowsCredentialsOfThisTabX, credentials); + } + /// /// Gets the command to redirect the selected host to another application. /// @@ -1190,10 +1242,11 @@ private void RescanSelectedHosts() _cancellationTokenSource?.Dispose(); _cancellationTokenSource = new CancellationTokenSource(); - // Same options (columns, ports), but every host is reported - also if it is unreachable now. Windows credentials - // that were rejected since the last scan are not used again. + // Same options (columns, ports), but every host is reported - also if it is unreachable now. The current + // Windows credentials of the tab (entered since the last scan, or rejected since then: not used again) var rescanOptions = CreateRescanOptions(_lastScanOptions) with { + WindowsCredentials = _windowsCredentials, WindowsCredentialsRejected = _isWindowsCredentialsRejected }; diff --git a/Source/NETworkManager/ViewModels/WindowsCredentialsChildWindowViewModel.cs b/Source/NETworkManager/ViewModels/WindowsCredentialsChildWindowViewModel.cs new file mode 100644 index 0000000000..f818310e7c --- /dev/null +++ b/Source/NETworkManager/ViewModels/WindowsCredentialsChildWindowViewModel.cs @@ -0,0 +1,51 @@ +using System; +using System.Windows.Input; +using NETworkManager.Models.Network; +using NETworkManager.Utilities; + +namespace NETworkManager.ViewModels; + +/// +/// Windows credentials of an IP Scanner tab ("Windows credentials..." in the options, "Scan as..." of a profile), +/// see . Only kept in memory, never saved. +/// +public class WindowsCredentialsChildWindowViewModel : ViewModelBase +{ + /// + /// Creates the dialog with the current credentials. + /// + /// Called with the dialog on OK. + /// Called with the dialog on Cancel. + /// Current credentials (the password stays unless a new one is entered), null for the + /// user running the application. + public WindowsCredentialsChildWindowViewModel(Action okCommand, + Action cancelHandler, WindowsCredentials credentials) + { + OKCommand = new RelayCommand(_ => okCommand(this)); + CancelCommand = new RelayCommand(_ => cancelHandler(this)); + + // Not saved: no warning about a profile file that is not encrypted + Credentials = new WindowsCredentialsViewModel(credentials != null, credentials?.Username, + credentials?.Domain, credentials?.Password, true); + } + + public ICommand OKCommand { get; } + + public ICommand CancelCommand { get; } + + /// + /// Username, domain and password ("Use credentials" off: the user running the application). + /// + public WindowsCredentialsViewModel Credentials { get; } + + /// + /// Gets the entered credentials (copy of the password), null for the user running the application. + /// + public WindowsCredentials ToCredentials() + { + return Credentials.UseCredentials + ? new WindowsCredentials(Credentials.Username?.Trim() ?? string.Empty, + Credentials.Domain?.Trim() ?? string.Empty, Credentials.Password?.Copy()) + : null; + } +} diff --git a/Source/NETworkManager/Views/IPScannerHostView.xaml b/Source/NETworkManager/Views/IPScannerHostView.xaml index b888d10ef1..7eb6fad9f6 100644 --- a/Source/NETworkManager/Views/IPScannerHostView.xaml +++ b/Source/NETworkManager/Views/IPScannerHostView.xaml @@ -52,6 +52,17 @@ + + + + + + + + + diff --git a/Source/NETworkManager/Views/IPScannerView.xaml b/Source/NETworkManager/Views/IPScannerView.xaml index 2cc5d7e395..5e85ce5ee3 100644 --- a/Source/NETworkManager/Views/IPScannerView.xaml +++ b/Source/NETworkManager/Views/IPScannerView.xaml @@ -181,10 +181,13 @@ - + + diff --git a/Source/NETworkManager/Views/WindowsCredentialsChildWindow.xaml b/Source/NETworkManager/Views/WindowsCredentialsChildWindow.xaml new file mode 100644 index 0000000000..2261a86f6e --- /dev/null +++ b/Source/NETworkManager/Views/WindowsCredentialsChildWindow.xaml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + +