Skip to content

Commit 1e7613a

Browse files
committed
few more improvements
1 parent b38ba3a commit 1e7613a

5 files changed

Lines changed: 8 additions & 21 deletions

File tree

src/ADEffectiveAccess/DirectoryEntryBuilder.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ internal sealed class DirectoryEntryBuilder : IDisposable
1212

1313
private readonly AuthenticationTypes _authenticationTypes;
1414

15-
// internal DirectoryEntry RootDSE { get; }
16-
1715
internal DirectoryEntry RootEntry { get; }
1816

1917
internal DirectoryEntry SearchBase { get; }
@@ -29,9 +27,7 @@ internal DirectoryEntryBuilder(
2927
_username = credential?.UserName;
3028
_password = credential?.GetNetworkCredential().Password;
3129
_authenticationTypes = authenticationTypes;
32-
// RootDSE = Create(server is null ? "RootDSE" : $"{server}/RootDSE");
3330
RootEntry = Create(server: server);
34-
// Root = RootEntry.Properties["distinguishedName"][0]?.ToString();
3531
SearchBase = Create(searchBase: searchBase);
3632
}
3733

@@ -48,15 +44,10 @@ internal DirectoryEntry Create(string? server = null, string? searchBase = null)
4844
return new(path, _username, _password, _authenticationTypes);
4945
}
5046

51-
// internal string GetRootProperty(string property) =>
52-
// RootDSE.Properties[property][0]?.ToString()
53-
// ?? throw RootDSE.ToInitializeResolverException(property);
54-
5547
public void Dispose()
5648
{
5749
RootEntry.Dispose();
5850
SearchBase.Dispose();
59-
// RootDSE.Dispose();
6051
GC.SuppressFinalize(this);
6152
}
6253
}

src/ADEffectiveAccess/Extensions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Diagnostics.CodeAnalysis;
43
using System.DirectoryServices;
54
using System.Management.Automation;
65
using System.Security.Principal;
76
using System.Text;
7+
#if !NETCOREAPP
8+
using System.Collections.Generic;
9+
#endif
810

911
namespace ADEffectiveAccess;
1012

src/ADEffectiveAccess/GetADEffectiveAccessComand.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,6 @@ _ when LanguagePrimitives.TryConvertTo(identity, out SecurityIdentifier sid) =>
169169
SearchResult result = searcher.FindOne()
170170
?? throw identity.ToIdentityNotFoundException(builder.Root);
171171

172-
if (!result.TryGetProperty(SecurityDescriptor, out byte[]? descriptor))
173-
{
174-
result.WriteInvalidSecurityDescriptorError(this);
175-
return;
176-
}
177-
178172
WriteRules(result);
179173
}
180174

src/ADEffectiveAccess/GuidResolver.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ private GuidResolver() { }
2525
internal void SetContext(string? server, DirectoryEntryBuilder builder)
2626
{
2727
using DirectoryEntry rootDSE = builder.Create(server, "RootDSE");
28-
string ctxName = rootDSE.GetRootProperty(DefaultContext);
28+
string context = rootDSE.GetRootProperty(DefaultContext);
2929

30-
if (_map.TryGetValue(ctxName, out Dictionary<Guid, string>? current))
30+
if (_map.TryGetValue(context, out Dictionary<Guid, string>? current))
3131
{
3232
_current = current;
3333
return;
3434
}
3535

36-
_current = _map[ctxName] = [];
36+
_current = _map[context] = [];
3737
string schemaNamingContext = rootDSE.GetRootProperty(SchemaContext);
3838
string extendedRights = $"CN=Extended-Rights,{rootDSE.GetRootProperty(ConfigurationContext)}";
3939

src/ADEffectiveAccess/RunspaceSpecificStorage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ namespace ADEffectiveAccess;
77

88
internal sealed class RunspaceSpecificStorage<T>(Func<T> factory)
99
{
10-
internal readonly ConditionalWeakTable<Runspace, Lazy<T>> _map = new();
11-
1210
private readonly Func<T> _factory = factory;
1311

1412
private readonly LazyThreadSafetyMode _mode = LazyThreadSafetyMode.ExecutionAndPublication;
1513

14+
internal readonly ConditionalWeakTable<Runspace, Lazy<T>> _map = new();
15+
1616
internal T GetFromTLS() => GetForRunspace(Runspace.DefaultRunspace);
1717

1818
internal T GetForRunspace(Runspace runspace)

0 commit comments

Comments
 (0)