Skip to content

Commit

Permalink
Merge pull request #49 from sysadminanywhere/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sysadminanywhere authored Oct 21, 2023
2 parents b0f1faf + d43c529 commit a4bf24c
Show file tree
Hide file tree
Showing 33 changed files with 512 additions and 132 deletions.
2 changes: 1 addition & 1 deletion src/SetupProject/Product.wxs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"><?define Sysadmin_TargetDir=$(var.Sysadmin.TargetDir)?>
<Product Id="*" Name="Sysadmin" Language="1033" Version="10.2.0.0" Manufacturer="Sysadmin Anywhere" UpgradeCode="ef8f7793-3a07-4cbb-ac9b-52eff7e8fb22">
<Product Id="*" Name="Sysadmin" Language="1033" Version="10.3.0.0" Manufacturer="Sysadmin Anywhere" UpgradeCode="ef8f7793-3a07-4cbb-ac9b-52eff7e8fb22">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
Expand Down
1 change: 1 addition & 0 deletions src/SysAdmin.ActiveDirectory/ADAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace SysAdmin.ActiveDirectory
{
[AttributeUsage(AttributeTargets.All, Inherited = true)]
public class ADAttribute : Attribute
{

Expand Down
24 changes: 12 additions & 12 deletions src/SysAdmin.ActiveDirectory/ADContainers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ namespace SysAdmin.ActiveDirectory
{
public class ADContainers
{
private const string ContainerMicrosoft = "B:32:F4BE92A4C777485E878E9421D53087DB:"; //CN=Microsoft,CN=Program Data,DC=example,DC=com
private const string ContainerProgramData = "B:32:09460C08AE1E4A4EA0F64AEE7DAA1E5A:"; //CN=Program Data,DC=example,DC=com
private const string ContainerForeignSecurityPrincipals = "B:32:22B70C67D56E4EFB91E9300FCA3DC1AA:"; //CN=ForeignSecurityPrincipals,DC=example,DC=com
private const string ContainerDeletedObjects = "B:32:18E2EA80684F11D2B9AA00C04F79F805:"; //CN=Deleted Objects,DC=example,DC=com
private const string ContainerInfrastructure = "B:32:2FBAC1870ADE11D297C400C04FD8D5CD:"; //CN=Infrastructure,DC=example,DC=com
private const string ContainerLostAndFound = "B:32:AB8153B7768811D1ADED00C04FD8D5CD:"; //CN=LostAndFound,DC=example,DC=com
private const string ContainerSystem = "B:32:AB1D30F3768811D1ADED00C04FD8D5CD:"; //CN=System,DC=example,DC=com
private const string ContainerDomainControllers = "B:32:A361B2FFFFD211D1AA4B00C04FD7D83A:"; //OU=Domain Controllers,DC=example,DC=com
private const string ContainerComputers = "B:32:AA312825768811D1ADED00C04FD8D5CD:"; //CN=Computers,DC=example,DC=com
private const string ContainerUsers = "B:32:A9D1CA15768811D1ADED00C04FD8D5CD:"; //CN=Users,DC=example,DC=com
private const string ContainerNTDSQuotas = "B:32:6227F0AF1FC2410D8E3BB10615BB5B0F:"; //CN=NTDS Quotas,DC=example,DC=com
private const string ContainerMicrosoft = "B:32:F4BE92A4C777485E878E9421D53087DB:"; //NOSONAR CN=Microsoft,CN=Program Data,DC=example,DC=com
private const string ContainerProgramData = "B:32:09460C08AE1E4A4EA0F64AEE7DAA1E5A:"; //NOSONAR CN=Program Data,DC=example,DC=com
private const string ContainerForeignSecurityPrincipals = "B:32:22B70C67D56E4EFB91E9300FCA3DC1AA:"; //NOSONAR CN=ForeignSecurityPrincipals,DC=example,DC=com
private const string ContainerDeletedObjects = "B:32:18E2EA80684F11D2B9AA00C04F79F805:"; //NOSONAR CN=Deleted Objects,DC=example,DC=com
private const string ContainerInfrastructure = "B:32:2FBAC1870ADE11D297C400C04FD8D5CD:"; //NOSONAR CN=Infrastructure,DC=example,DC=com
private const string ContainerLostAndFound = "B:32:AB8153B7768811D1ADED00C04FD8D5CD:"; //NOSONAR CN=LostAndFound,DC=example,DC=com
private const string ContainerSystem = "B:32:AB1D30F3768811D1ADED00C04FD8D5CD:"; //NOSONAR CN=System,DC=example,DC=com
private const string ContainerDomainControllers = "B:32:A361B2FFFFD211D1AA4B00C04FD7D83A:"; //NOSONAR OU=Domain Controllers,DC=example,DC=com
private const string ContainerComputers = "B:32:AA312825768811D1ADED00C04FD8D5CD:"; //NOSONAR CN=Computers,DC=example,DC=com
private const string ContainerUsers = "B:32:A9D1CA15768811D1ADED00C04FD8D5CD:"; //NOSONAR CN=Users,DC=example,DC=com
private const string ContainerNTDSQuotas = "B:32:6227F0AF1FC2410D8E3BB10615BB5B0F:"; //NOSONAR CN=NTDS Quotas,DC=example,DC=com

private List<string> wellKnownObjects;
private readonly List<string> wellKnownObjects;

public ADContainers(LdapService ldapService)
{
Expand Down
4 changes: 2 additions & 2 deletions src/SysAdmin.ActiveDirectory/ADHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ public static class ADHelper
{
public static string ExtractCN(string dn)
{
string[] parts = dn.Split(new char[] { ',' });
string[] parts = dn.Split(",");

for (int i = 0; i < parts.Length; i++)
{
var p = parts[i];
var elems = p.Split(new char[] { '=' });
var elems = p.Split("=");
var t = elems[0].Trim().ToUpper();
var v = elems[1].Trim();
if (t == "CN")
Expand Down
4 changes: 2 additions & 2 deletions src/SysAdmin.ActiveDirectory/ADResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static T GetValues(LdapEntry entry)

var attributes = (ADAttribute[])property.GetCustomAttributes(typeof(ADAttribute), true);

if (attributes.Count() > 0)
if (attributes != null && attributes.Any())
{
propertyName = attributes[0].Name;
dateType = attributes[0].DateType;
Expand All @@ -35,7 +35,7 @@ public static T GetValues(LdapEntry entry)
try
{

var attribute = directoryAttributes.Where(a => a.Name.ToLower() == propertyName.ToLower()).FirstOrDefault();
var attribute = directoryAttributes.FirstOrDefault(a => a.Name.ToLower() == propertyName.ToLower());

if (attribute != null)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Sysadmin/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledEx
// For more info see https://docs.microsoft.com/en-us/dotnet/api/system.windows.application.dispatcherunhandledexception?view=windowsdesktop-6.0
}

public static IServer SERVER = null;
public static ICredential CREDENTIAL = null;
public static ADContainers CONTAINERS = null;
public static IServer? SERVER = null; //NOSONAR
public static ICredential? CREDENTIAL = null; //NOSONAR
public static ADContainers? CONTAINERS = null; //NOSONAR

}
}
2 changes: 1 addition & 1 deletion src/Sysadmin/Controls/MemberOfControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</Grid.RowDefinitions>

<Grid Grid.Row="0">
<TextBlock Text="Member of" Margin="0,8,8,8" HorizontalAlignment="Left" FontWeight="Bold"/>
<TextBlock Text="Member of" Margin="0" HorizontalAlignment="Left" FontWeight="Bold"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button x:Name="addButton" Content="+" Click="addButton_Click"/>
<Button x:Name="deleteButton" Content="-" IsEnabled="False" Click="deleteButton_Click"/>
Expand Down
10 changes: 5 additions & 5 deletions src/Sysadmin/Controls/MemberOfControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public int PrimaryGroupId
SetValue(PrimaryGroupIdProperty, value);
if (value != 0)
{
string group = SysAdmin.ActiveDirectory.ADHelper.GetPrimaryGroup(value);
string group = ADHelper.GetPrimaryGroup(value);
if (!string.IsNullOrEmpty(group))
if (Items.FirstOrDefault(c => c.Name == group) == null)
Items.Add(new MemberItem() { Name = group, DistinguishedName = string.Empty });
Expand All @@ -114,11 +114,11 @@ private void Update(List<string> value)
Items.Clear();
if (value != null)
foreach (string item in value)
Items.Add(new MemberItem() { Name = SysAdmin.ActiveDirectory.ADHelper.ExtractCN(item), DistinguishedName = item });
Items.Add(new MemberItem() { Name = ADHelper.ExtractCN(item), DistinguishedName = item });

if (PrimaryGroupId != 0)
{
string group = SysAdmin.ActiveDirectory.ADHelper.GetPrimaryGroup(PrimaryGroupId);
string group = ADHelper.GetPrimaryGroup(PrimaryGroupId);
if (!string.IsNullOrEmpty(group))
Items.Add(new MemberItem() { Name = group, DistinguishedName = string.Empty });
}
Expand Down Expand Up @@ -147,7 +147,7 @@ private void addButton_Click(object sender, RoutedEventArgs e)
selectControl.Load(SelectControl.Show.Groups);
}

private async void deleteButton_Click(object sender, RoutedEventArgs e)
private async void deleteButton_Click(object sender, RoutedEventArgs e) //NOSONAR
{
try
{
Expand Down Expand Up @@ -206,7 +206,7 @@ await Task.Run(async () =>
});
}

private async void selectControl_SelectedItem(MemberItem item)
private async void selectControl_SelectedItem(MemberItem item) //NOSONAR
{
flyout.Hide();

Expand Down
2 changes: 1 addition & 1 deletion src/Sysadmin/Controls/MembersControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</Grid.RowDefinitions>

<Grid Grid.Row="0">
<TextBlock Text="Members" Margin="0,8,8,8" HorizontalAlignment="Left" FontWeight="Bold" VerticalAlignment="Top"/>
<TextBlock Text="Members" Margin="0" HorizontalAlignment="Left" FontWeight="Bold" VerticalAlignment="Top"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button x:Name="addButton" Content="+" Click="addButton_Click"/>
<Button x:Name="deleteButton" Content="-" IsEnabled="False" Click="deleteButton_Click"/>
Expand Down
4 changes: 2 additions & 2 deletions src/Sysadmin/Controls/MembersControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void addButton_Click(object sender, RoutedEventArgs e)
selectControl.Load(SelectControl.Show.All);
}

private async void deleteButton_Click(object sender, RoutedEventArgs e)
private async void deleteButton_Click(object sender, RoutedEventArgs e) //NOSONAR
{
try
{
Expand Down Expand Up @@ -161,7 +161,7 @@ await Task.Run(async () =>
}


private async void selectControl_SelectedItem(MemberItem item)
private async void selectControl_SelectedItem(MemberItem item) //NOSONAR
{
flyout.Hide();

Expand Down
22 changes: 22 additions & 0 deletions src/Sysadmin/Controls/PersonPictureControl.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<UserControl xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" x:Class="Sysadmin.Controls.PersonPictureControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Sysadmin.Controls"
mc:Ignorable="d"
d:DesignHeight="100" d:DesignWidth="100">
<Grid>
<Ellipse Fill="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" />
<Viewbox>
<TextBlock Margin="4" Text="PP" x:Name="initials" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
</Viewbox>
<Viewbox>
<Image x:Name="pictureImage" RenderOptions.BitmapScalingMode="HighQuality" Width="100" Height="100">
<Image.Clip>
<EllipseGeometry Center="50,50" RadiusX="50" RadiusY="50" />
</Image.Clip>
</Image>
</Viewbox>
</Grid>
</UserControl>
106 changes: 106 additions & 0 deletions src/Sysadmin/Controls/PersonPictureControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
using System;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace Sysadmin.Controls
{
/// <summary>
/// Interaction logic for PersonPictureControl.xaml
/// </summary>
public partial class PersonPictureControl : UserControl
{

public static readonly DependencyProperty DisplayNameProperty = DependencyProperty.Register(
"DisplayName", typeof(string),
typeof(PersonPictureControl)
);

public string DisplayName
{
get => (string)GetValue(DisplayNameProperty);
set
{
SetValue(DisplayNameProperty, value);
initials.Text = GetInitials(value);
}
}

public static readonly DependencyProperty ProfilePictureProperty = DependencyProperty.Register(
"ProfilePicture", typeof(ImageSource),
typeof(PersonPictureControl)
);

public ImageSource ProfilePicture
{
get => (ImageSource)GetValue(ProfilePictureProperty);
set
{
SetValue(ProfilePictureProperty, value);
pictureImage.Source = value;
}
}

private byte[] jpegPhoto;

public byte[] JpegPhoto
{
get { return jpegPhoto; }
set
{
jpegPhoto = value;
ShowPhoto();
}
}

public PersonPictureControl()
{
InitializeComponent();
}

private string GetInitials(string name)
{

if (string.IsNullOrEmpty(name))
return string.Empty;

string[] nameSplit = name.Split(new string[] { ",", " " }, StringSplitOptions.RemoveEmptyEntries);

string initials = "";

foreach (string item in nameSplit)
{
initials += item.Substring(0, 1).ToUpper();
}

return initials;
}

private void ShowPhoto()
{
if (JpegPhoto != null && JpegPhoto.Length > 0)
{
var image = new BitmapImage();
using (var mem = new MemoryStream(JpegPhoto))
{
mem.Position = 0;
image.BeginInit();
image.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
image.CacheOption = BitmapCacheOption.OnLoad;
image.UriSource = null;
image.StreamSource = mem;
image.EndInit();
}
image.Freeze();
pictureImage.Source = image;
}
else
{
pictureImage.Source = null;
}
}

}
}
4 changes: 4 additions & 0 deletions src/Sysadmin/Services/ISettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ public interface ISettingsService

bool LoginUseCredentials { get; set; }

string VNCPath { get; set; }

int VNCPort { get; set; }

}
}
20 changes: 20 additions & 0 deletions src/Sysadmin/Services/SettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,26 @@ public bool LoginUseCredentials
set { SetValue("LoginUseCredentials", value); }
}

public string VNCPath
{
get
{
return GetStringValue("VNCPath", "C:\\Program Files\\TightVNC\\tvnviewer.exe");
}
set { SetValue("VNCPath", value); }
}

public int VNCPort
{
get
{
return GetIntValue("VNCPort", 5900);
}
set { SetValue("VNCPort", value); }
}



public void LoadSettings()
{
try
Expand Down
1 change: 1 addition & 0 deletions src/Sysadmin/Styles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
</Style>

<Style x:Key="ListDescriptionStyle" TargetType="TextBlock">
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="TextTrimming" Value="CharacterEllipsis"/>
<Setter Property="Margin" Value="6,0,0,6" />
<Setter Property="VerticalAlignment" Value="Center" />
Expand Down
8 changes: 4 additions & 4 deletions src/Sysadmin/Sysadmin.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
Expand All @@ -9,9 +9,9 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>applicationIcon.ico</ApplicationIcon>
<Title>Sysadmin</Title>
<AssemblyVersion>10.2.0</AssemblyVersion>
<Version>10.2.0</Version>
<FileVersion>10.2.0</FileVersion>
<AssemblyVersion>10.3.0</AssemblyVersion>
<Version>10.3.0</Version>
<FileVersion>10.3.0</FileVersion>
<Copyright>Copyright 2015-2023 Sysadmin Anywhere - All Rights Reserved</Copyright>
<Company>Sysadmin Anywhere</Company>
<Authors>Sysadmin Anywhere</Authors>
Expand Down
6 changes: 6 additions & 0 deletions src/Sysadmin/ToDo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@
10. Autoupdater.NET
+ Version
+ XML
11. Remote desktop
+ VNC
+ RDP
12. Member of
+ User
+ Computer
Loading

0 comments on commit a4bf24c

Please sign in to comment.