Skip to content

Commit d3fe776

Browse files
Release 3.4.1.31 candidate changes. (#293)
Release information: https://community.netwrix.com/t/minor-version-3-4-released/14949 Signed-off-by: HerbieSmith-Netwrix <[email protected]>
1 parent 4a7619b commit d3fe776

File tree

192 files changed

+5501
-4389
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+5501
-4389
lines changed

ADWS/ADItem.cs

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ protected ADItem()
208208
public string[] msDSEnabledFeature { get; set; }
209209
[ADAttributeAttribute("msDS-ExpirePasswordsOnSmartCardOnlyAccounts", ADAttributeValueKind.BoolValue)]
210210
public bool msDSExpirePasswordsOnSmartCardOnlyAccounts { get; set; }
211+
[ADAttributeAttribute("msDS-isGC", ADAttributeValueKind.BoolValue)]
212+
public bool? msDSIsGC { get; set; }
213+
[ADAttributeAttribute("msDS-IsRODC", ADAttributeValueKind.BoolValue)]
214+
public bool? msDSisRodc { get; set; }
211215
[ADAttributeAttribute("msDS-IntId", ADAttributeValueKind.IntValue)]
212216
public int msDSIntId { get; set; }
213217
[ADAttributeAttribute("msDS-SupportedEncryptionTypes", ADAttributeValueKind.IntValue)]
@@ -340,6 +344,9 @@ protected ADItem()
340344
[ADAttributeAttribute("whenChanged", ADAttributeValueKind.DateValue2)]
341345
public DateTime WhenChanged { get; set; }
342346

347+
[ADAttributeAttribute("mspki-ra-signature", ADAttributeValueKind.IntValue)]
348+
public int AuthorizedSignatures { get; set; }
349+
343350
public List<string> GetApplicableGPO()
344351
{
345352
var output = new List<string>();
@@ -498,27 +505,6 @@ internal static List<HealthCheckTrustDomainInfoData> ConvertByteToTrustInfo(byte
498505
}
499506
else if (recordType == 4)
500507
{
501-
/*Trace.WriteLine("RecordType 4");
502-
int tempPointer = pointer + recordSize;
503-
int binaryDataLen = BitConverter.ToInt32(data, tempPointer);
504-
tempPointer += 4;
505-
int subRecordType = BitConverter.ToInt32(data, tempPointer);
506-
tempPointer += 4;
507-
int sidLen = data[ tempPointer];
508-
tempPointer += 1;
509-
if (sidLen > 0)
510-
{
511-
SecurityIdentifier sid = new SecurityIdentifier(data, tempPointer);
512-
tempPointer += sidLen;
513-
}
514-
int DnsNameLen = BitConverter.ToInt32(data, tempPointer);
515-
tempPointer += 4;
516-
string DnsName = UnicodeEncoding.UTF8.GetString(data, tempPointer, DnsNameLen);
517-
tempPointer += DnsNameLen;
518-
int NetbiosNameLen = BitConverter.ToInt32(data, tempPointer);
519-
tempPointer += 4;
520-
string NetbiosName = UnicodeEncoding.UTF8.GetString(data, tempPointer, NetbiosNameLen);
521-
tempPointer += NetbiosNameLen;*/
522508
}
523509
else
524510
{
@@ -981,13 +967,14 @@ public static ADItem Create(SearchResult sr, bool nTSecurityDescriptor)
981967
return aditem;
982968
}
983969

984-
static void NotImplemented(string name, ADAttributeValueKind kind, berval[] val)
970+
private static void NotImplemented(string name, ADAttributeValueKind kind, berval[] val)
985971
{
986-
Console.WriteLine("name:" + name);
987-
Console.WriteLine("kind: " + kind.ToString());
972+
var ui = UserInterfaceFactory.GetUserInterface();
973+
ui.DisplayMessage("name:" + name);
974+
ui.DisplayMessage("kind: " + kind.ToString());
988975
if (val == null)
989976
return;
990-
Console.WriteLine("val: " + val[0].ToString());
977+
ui.DisplayMessage("val: " + val[0].ToString());
991978
throw new NotImplementedException();
992979
}
993980
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
@@ -1131,7 +1118,7 @@ public static ADItem Create(Dictionary<string, berval[]> data)
11311118
}
11321119
break;
11331120
case ADAttributeValueKind.ReplMetadataValue:
1134-
translation.prop.SetValue(aditem, ConvertByteToMetaDataInfo(((berval)data[name2][0]).GetByteArray()), null);
1121+
translation.prop.SetValue(aditem, ConvertByteToMetaDataInfo(data[name2][0].GetByteArray()), null);
11351122
break;
11361123
case ADAttributeValueKind.ReplMetadataValue2:
11371124
{

ADWS/ADWSConnection.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,19 @@
44
//
55
// Licensed under the Non-Profit OSL. See LICENSE file in the project root for full license information.
66
//
7-
using PingCastle.misc;
7+
using PingCastle.UserInterface;
88
using System;
99
using System.Collections.Generic;
1010
using System.Diagnostics;
11-
using System.DirectoryServices.ActiveDirectory;
1211
using System.IO;
1312
using System.Net;
14-
using System.Runtime.Serialization;
1513
using System.Security.Permissions;
1614
using System.ServiceModel;
17-
using System.Text;
18-
using System.Threading;
1915
using System.Xml;
2016

2117
namespace PingCastle.ADWS
2218
{
23-
public class ADWSConnection : ADConnection
19+
public class ADWSConnection : ADConnection
2420
{
2521

2622
public ADWSConnection(string server, int port, NetworkCredential credential)
@@ -34,9 +30,11 @@ public ADWSConnection(string server, int port, NetworkCredential credential)
3430

3531
private delegate void ReceiveItems(ItemListType items);
3632

37-
// when doing a simple enumeration, ws-transfert (for root dse) and ws-enumeration needs to be called.
38-
// share the connection between the 2 webservices to save time
39-
private NetTcpBinding _binding = null;
33+
private readonly IUserInterface _ui = UserInterfaceFactory.GetUserInterface();
34+
35+
// when doing a simple enumeration, ws-transfert (for root dse) and ws-enumeration needs to be called.
36+
// share the connection between the 2 webservices to save time
37+
private NetTcpBinding _binding = null;
4038
private NetTcpBinding Binding
4139
{
4240
get
@@ -237,7 +235,7 @@ public override void Enumerate(string distinguishedName, string filter, string[]
237235
}
238236
catch (Exception ex)
239237
{
240-
Console.WriteLine("Warning: unable to process element (" + ex.Message + ")\r\n" + item.OuterXml);
238+
_ui.DisplayWarning("Warning: unable to process element (" + ex.Message + ")\r\n" + item.OuterXml);
241239
Trace.WriteLine("Warning: unable to process element\r\n" + item.OuterXml);
242240
Trace.WriteLine("Exception: " + ex.ToString());
243241
}

ADWS/ADWebService.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//
55
// Licensed under the Non-Profit OSL. See LICENSE file in the project root for full license information.
66
//
7+
using PingCastle.UserInterface;
78
using System;
89
using System.Collections.Generic;
910
using System.Diagnostics;
@@ -65,6 +66,8 @@ public ADWebService(string server, int port, NetworkCredential credential)
6566
private IADConnection connection { get; set; }
6667
private IADConnection fallBackConnection { get; set; }
6768

69+
private readonly IUserInterface _ui = UserInterfaceFactory.GetUserInterface();
70+
6871
#region connection establishment
6972
private void EstablishConnection()
7073
{
@@ -297,9 +300,9 @@ public void Enumerate(Action preambleWithReentry, string distinguishedName, stri
297300
Trace.WriteLine("StackTrace: " + ex.StackTrace);
298301
if (fallBackConnection == null)
299302
throw;
300-
Console.ForegroundColor = ConsoleColor.Yellow;
301-
Console.WriteLine("The AD query failed. Using the alternative protocol (" + fallBackConnection.GetType().Name + ")");
302-
Console.ResetColor();
303+
304+
_ui.DisplayWarning("The AD query failed. Using the alternative protocol (" + fallBackConnection.GetType().Name + ")");
305+
303306
if (preambleWithReentry != null)
304307
preambleWithReentry();
305308
fallBackConnection.Enumerate(distinguishedName, filter, properties, callback, scope);

ADWS/LDAPConnection.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//
55
// Licensed under the Non-Profit OSL. See LICENSE file in the project root for full license information.
66
//
7+
using PingCastle.UserInterface;
78
using System;
89
using System.Diagnostics;
910
using System.DirectoryServices;
@@ -25,6 +26,7 @@ public LDAPConnection(string server, int port, NetworkCredential credential)
2526
Credential = credential;
2627
}
2728
public static int PageSize = 500;
29+
private readonly IUserInterface _userIo = UserInterfaceFactory.GetUserInterface();
2830

2931
public override void Enumerate(string distinguishedName, string filter, string[] properties, WorkOnReturnedObjectByADWS callback, string scope)
3032
{
@@ -93,17 +95,15 @@ private void EnumerateInternalWithLDAP(string distinguishedName, string filter,
9395
{
9496
if (ex.ErrorCode == -2147024662 && ex.ExtendedError == 234)
9597
{
96-
Console.ForegroundColor = ConsoleColor.Yellow;
97-
Console.WriteLine("[" + DateTime.Now.ToLongTimeString() + "] Warning: received \"Calling GetNextRow can potentially return more results\"");
98+
_userIo.DisplayWarning("[" + DateTime.Now.ToLongTimeString() + "] Warning: received \"Calling GetNextRow can potentially return more results\"");
9899
Trace.WriteLine("[" + DateTime.Now.ToLongTimeString() + "] Warning: received \"Calling GetNextRow can potentially return more results\"");
99-
Console.ResetColor();
100100
if (!iterator.MoveNext())
101101
{
102-
Console.WriteLine("[" + DateTime.Now.ToLongTimeString() + "] No more results");
102+
_userIo.DisplayMessage("[" + DateTime.Now.ToLongTimeString() + "] No more results");
103103
Trace.WriteLine("[" + DateTime.Now.ToLongTimeString() + "] No more results");
104104
break;
105105
}
106-
Console.WriteLine("[" + DateTime.Now.ToLongTimeString() + "] More results found");
106+
_userIo.DisplayMessage("[" + DateTime.Now.ToLongTimeString() + "] More results found");
107107
Trace.WriteLine("[" + DateTime.Now.ToLongTimeString() + "] More results found");
108108
}
109109
else
@@ -120,7 +120,7 @@ private void EnumerateInternalWithLDAP(string distinguishedName, string filter,
120120
}
121121
catch (Exception ex)
122122
{
123-
Console.WriteLine("Warning: unable to process element (" + ex.Message + ")\r\n" + sr.Path);
123+
_userIo.DisplayWarning("Warning: unable to process element (" + ex.Message + ")\r\n" + sr.Path);
124124
Trace.WriteLine("Warning: unable to process element\r\n" + sr.Path);
125125
Trace.WriteLine("Exception: " + ex.ToString());
126126
}
@@ -227,10 +227,10 @@ private void EnsureLDAPSIsWorking()
227227
Trace.WriteLine("SSLPolicyErrors: " + sslPolicyErrors);
228228
if (sslPolicyErrors != SslPolicyErrors.None)
229229
{
230-
Console.WriteLine("While testing the LDAPS certificate, PingCastle found the following error: " + sslPolicyErrors);
231-
Console.WriteLine("The certificate is untrusted and Windows prohibits PingCastle to connect to it");
232-
Console.WriteLine("Certificate: " + CACert.Subject);
233-
Console.WriteLine("Expires: " + CACert.GetExpirationDateString());
230+
_userIo.DisplayMessage("While testing the LDAPS certificate, PingCastle found the following error: " + sslPolicyErrors);
231+
_userIo.DisplayMessage("The certificate is untrusted and Windows prohibits PingCastle to connect to it");
232+
_userIo.DisplayMessage("Certificate: " + CACert.Subject);
233+
_userIo.DisplayMessage("Expires: " + CACert.GetExpirationDateString());
234234
}
235235
return true;
236236
}

ADWS/LinuxConnection.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ public string GetString()
3030
if (bv_val == IntPtr.Zero)
3131
return null;
3232
return Marshal.PtrToStringAuto(bv_val, bv_len);
33-
/*var bytes = GetByteArray();
34-
return Encoding.UTF8.GetString(bytes, 0, bytes.Length);*/
3533

3634
}
3735

ADWS/LinuxSidResolver.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
namespace PingCastle.ADWS
1010
{
11+
public static class LinuxSidResolverSettings
12+
{
13+
public static string LogLevel { get; set; }
14+
}
15+
1116
internal class LinuxSidResolver : IDisposable
1217
{
1318
const int SECURITY_MAX_SID_SIZE = 68;
@@ -91,8 +96,6 @@ internal static extern int rpccli_lsa_lookup_names(IntPtr cli,
9196
[DllImport(SmbLibrary, CharSet = CharSet.Ansi)]
9297
internal static extern void lp_set_cmdline(string i, string j);
9398

94-
public static string LogLevel { get; set; }
95-
9699
IntPtr memoryContext;
97100
static object lockobject = new object();
98101
//in
@@ -139,9 +142,9 @@ private int ConnectWithFull()
139142
private void ConnectToLsa()
140143
{
141144
Trace.WriteLine(@"ConnectToLsa Init");
142-
if (!string.IsNullOrEmpty(LogLevel))
145+
if (!string.IsNullOrEmpty(LinuxSidResolverSettings.LogLevel))
143146
{
144-
lp_set_cmdline("log level", LogLevel);
147+
lp_set_cmdline("log level", LinuxSidResolverSettings.LogLevel);
145148
}
146149
lp_set_cmdline("client ipc signing", "required");
147150
var r = ConnectWithFull();

ADWS/WindowsFileConnection.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Runtime.InteropServices;
88
using System.Security.AccessControl;
99
using System.Security.Principal;
10-
using System.Text;
1110

1211
namespace PingCastle.ADWS
1312
{
@@ -47,8 +46,6 @@ public DirectorySecurity GetDirectorySecurity(string path)
4746

4847
public FileSecurity GetFileSecurity(string path)
4948
{
50-
/*var info = new FileInfo(path);
51-
return ((FileInfo)info).GetAccessControl();*/
5249
return File.GetAccessControl(path);
5350
}
5451

Bot/Bot.cs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
using PingCastle.PingCastleLicense;
44
using PingCastle.Report;
55
using PingCastle.Rules;
6+
using PingCastle.UserInterface;
67
using System;
78
using System.Collections.Generic;
8-
using System.ComponentModel;
99
using System.IO;
1010
using System.Text;
1111
using System.Xml;
@@ -17,13 +17,15 @@ namespace PingCastle.Bot
1717

1818
public class Bot
1919
{
20+
private readonly IUserInterface _userIo = UserInterfaceFactory.GetUserInterface();
21+
2022
public void Run(string pipeName)
2123
{
2224
BotInputOutput input;
2325
bool stop = false;
2426

2527
XmlSerializer xs = new XmlSerializer(typeof(BotInputOutput));
26-
Console.WriteLine("Bot: hello");
28+
_userIo.DisplayMessage("Bot: hello");
2729
using (var pipe = BotStream.OpenPipeStream(pipeName))
2830
{
2931
while (!stop)
@@ -42,25 +44,24 @@ public void Run(string pipeName)
4244
int r = pipe.Read(data, read, count - read);
4345
if (r == 0)
4446
{
45-
Console.WriteLine("Pipe shutdown");
47+
_userIo.DisplayMessage("Pipe shutdown");
4648
return;
4749
}
4850
read += r;
4951
}
50-
Console.WriteLine("Bot: message received");
52+
_userIo.DisplayMessage("Bot: message received");
5153
using (var ms = new MemoryStream(data))
5254
{
5355
input = (BotInputOutput)xs.Deserialize(ms);
5456
}
5557
}
5658
catch (Exception ex)
5759
{
58-
Console.WriteLine("Exception when reading the input " + ex.Message);
59-
Console.WriteLine("StackTrace:" + ex.StackTrace);
60+
_userIo.DisplayError("Exception when reading the input " + ex.Message);
61+
_userIo.DisplayStackTrace("StackTrace:" + ex.StackTrace);
6062
return;
6163
}
6264

63-
6465
BotInputOutput output;
6566
string order = GetItem(input, "Command");
6667
try
@@ -90,11 +91,11 @@ public void Run(string pipeName)
9091
catch (Exception ex)
9192
{
9293
output = ExceptionOutput("Exception during the job " + ex.Message, ex.StackTrace);
93-
Console.WriteLine("Exception:" + ex.Message);
94-
Console.WriteLine("StackTrace:" + ex.StackTrace);
94+
_userIo.DisplayMessage("Exception:" + ex.Message);
95+
_userIo.DisplayStackTrace("StackTrace:" + ex.StackTrace);
9596
}
9697

97-
Console.WriteLine("Writing data");
98+
_userIo.DisplayMessage("Writing data");
9899

99100
using (var ms = new MemoryStream())
100101
using (XmlWriter writer = XmlWriter.Create(ms))
@@ -105,11 +106,11 @@ public void Run(string pipeName)
105106
var t = BitConverter.GetBytes((int)ms.Length);
106107
pipe.Write(t, 0, 4);
107108
pipe.Write(buffer, 0, (int)ms.Length);
108-
Console.WriteLine("Bot: message sent");
109+
_userIo.DisplayMessage("Bot: message sent");
109110
}
110111
}
111112
}
112-
Console.WriteLine("Exiting");
113+
_userIo.DisplayMessage("Exiting");
113114
}
114115

115116
private string GetItem(BotInputOutput input, string key)
@@ -181,8 +182,8 @@ private BotInputOutput RunHealthCheck(BotInputOutput input)
181182
}
182183
catch (Exception ex)
183184
{
184-
Console.WriteLine("Exception:" + ex.Message);
185-
Console.WriteLine("StackTrace:" + ex.StackTrace);
185+
_userIo.DisplayError("Exception:" + ex.Message);
186+
_userIo.DisplayStackTrace("StackTrace:" + ex.StackTrace);
186187
return ExceptionOutput("Exception during the healthcheck " + ex.Message, ex.StackTrace);
187188
}
188189
}
@@ -195,9 +196,9 @@ private BotInputOutput ToHtml(BotInputOutput input)
195196
using (var ms = new MemoryStream(UnicodeEncoding.UTF8.GetBytes(xml)))
196197
{
197198
HealthcheckData healthcheckData = DataHelper<HealthcheckData>.LoadXml(ms, "bot", null);
198-
var endUserReportGenerator = new ReportHealthCheckSingle();
199199
var license = LicenseCache.Instance.GetLicense();
200-
var report = endUserReportGenerator.GenerateReportFile(healthcheckData, license, healthcheckData.GetHumanReadableFileName());
200+
var endUserReportGenerator = new ReportHealthCheckSingle(license);
201+
var report = endUserReportGenerator.GenerateReportFile(healthcheckData, healthcheckData.GetHumanReadableFileName());
201202

202203
var o = new BotInputOutput();
203204
o.Data = new List<BotData>();
@@ -208,8 +209,8 @@ private BotInputOutput ToHtml(BotInputOutput input)
208209
}
209210
catch (Exception ex)
210211
{
211-
Console.WriteLine("Exception:" + ex.Message);
212-
Console.WriteLine("StackTrace:" + ex.StackTrace);
212+
_userIo.DisplayError("Exception:" + ex.Message);
213+
_userIo.DisplayStackTrace("StackTrace:" + ex.StackTrace);
213214
return ExceptionOutput("Exception during the job " + ex.Message, ex.StackTrace);
214215
}
215216
}

0 commit comments

Comments
 (0)