Skip to content

Commit 2867c53

Browse files
Resolved #193: Call to GetAccounts returns NotImplementedException
1 parent 17a300b commit 2867c53

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

Src/DSInternals.PowerShell/Commands/Replication/GetADReplAccountCommand.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ protected override void BeginProcessing()
7474
{
7575
base.BeginProcessing();
7676

77-
// TODO: Retrieval of linked objects is not yet implemented in the replication client.
78-
this.Properties &= ~AccountPropertySets.ManagedBy;
79-
this.Properties &= ~AccountPropertySets.Manager;
80-
81-
// TODO: LAPS-related attribute schema loading is not yet implemented.
82-
this.Properties &= ~AccountPropertySets.LAPS;
83-
8477
if (this.ExportFormat != null)
8578
{
8679
// Override the property sets to match the requirements of the export formats.

Src/DSInternals.Replication/DirectoryReplicationClient.cs

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
using DSInternals.Common;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Net;
4+
using System.Security.Principal;
5+
using DSInternals.Common;
26
using DSInternals.Common.Cryptography;
37
using DSInternals.Common.Data;
48
using DSInternals.Common.Exceptions;
@@ -9,11 +13,6 @@
913
using NDceRpc;
1014
using NDceRpc.Microsoft.Interop;
1115
using NDceRpc.Native;
12-
using System;
13-
using System.Collections.Generic;
14-
using System.Net;
15-
using System.Security.Principal;
16-
using System.Security.AccessControl;
1716

1817
namespace DSInternals.Replication
1918
{
@@ -87,17 +86,19 @@ public ReplicationCursor[] GetReplicationCursors(string namingContext)
8786
return this.drsConnection.GetReplicationCursors(namingContext);
8887
}
8988

90-
public IEnumerable<DSAccount> GetAccounts(string domainNamingContext, ReplicationProgressHandler progressReporter = null, AccountPropertySets properties = AccountPropertySets.All)
89+
public IEnumerable<DSAccount> GetAccounts(string domainNamingContext, ReplicationProgressHandler progressReporter = null, AccountPropertySets propertySets = AccountPropertySets.All)
9190
{
9291
Validator.AssertNotNullOrWhiteSpace(domainNamingContext, nameof(domainNamingContext));
9392
ReplicationCookie cookie = new ReplicationCookie(domainNamingContext);
94-
return GetAccounts(cookie, progressReporter, properties);
93+
return GetAccounts(cookie, progressReporter, propertySets);
9594
}
9695

97-
public IEnumerable<DSAccount> GetAccounts(ReplicationCookie initialCookie, ReplicationProgressHandler progressReporter = null, AccountPropertySets properties = AccountPropertySets.All)
96+
public IEnumerable<DSAccount> GetAccounts(ReplicationCookie initialCookie, ReplicationProgressHandler progressReporter = null, AccountPropertySets propertySets = AccountPropertySets.All)
9897
{
9998
Validator.AssertNotNull(initialCookie, nameof(initialCookie));
10099

100+
propertySets = SkipUnsupportedProperties(propertySets);
101+
101102
// Create AD schema
102103
var schema = BasicSchemaFactory.CreateSchema();
103104
var currentCookie = initialCookie;
@@ -121,7 +122,7 @@ public IEnumerable<DSAccount> GetAccounts(ReplicationCookie initialCookie, Repli
121122
{
122123
obj.Schema = schema;
123124

124-
var account = AccountFactory.CreateAccount(obj, this.NetBIOSDomainName, this.SecretDecryptor, properties);
125+
var account = AccountFactory.CreateAccount(obj, this.NetBIOSDomainName, this.SecretDecryptor, propertySets);
125126

126127
if (account != null)
127128
{
@@ -137,6 +138,8 @@ public IEnumerable<DSAccount> GetAccounts(ReplicationCookie initialCookie, Repli
137138

138139
public DSAccount GetAccount(Guid objectGuid, AccountPropertySets propertySets = AccountPropertySets.All)
139140
{
141+
propertySets = SkipUnsupportedProperties(propertySets);
142+
140143
var obj = this.drsConnection.ReplicateSingleObject(objectGuid);
141144
var schema = BasicSchemaFactory.CreateSchema();
142145
obj.Schema = schema;
@@ -153,6 +156,8 @@ public DSAccount GetAccount(Guid objectGuid, AccountPropertySets propertySets =
153156

154157
public DSAccount GetAccount(string distinguishedName, AccountPropertySets propertySets = AccountPropertySets.All)
155158
{
159+
propertySets = SkipUnsupportedProperties(propertySets);
160+
156161
var obj = this.drsConnection.ReplicateSingleObject(distinguishedName);
157162
var schema = BasicSchemaFactory.CreateSchema();
158163
obj.Schema = schema;
@@ -321,5 +326,17 @@ private void LoadDomainInfo()
321326
NTAccount pdcAccount = this.drsConnection.ResolveAccountName(pdcAccountDN);
322327
this.netBIOSDomainName = pdcAccount.NetBIOSDomainName();
323328
}
329+
330+
private static AccountPropertySets SkipUnsupportedProperties(AccountPropertySets propertySets)
331+
{
332+
// TODO: Retrieval of linked objects is not yet implemented in the replication client.
333+
propertySets &= ~AccountPropertySets.ManagedBy;
334+
propertySets &= ~AccountPropertySets.Manager;
335+
336+
// TODO: LAPS-related attribute schema loading is not yet implemented.
337+
propertySets &= ~AccountPropertySets.LAPS;
338+
339+
return propertySets;
340+
}
324341
}
325342
}

0 commit comments

Comments
 (0)