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 ;
26using DSInternals . Common . Cryptography ;
37using DSInternals . Common . Data ;
48using DSInternals . Common . Exceptions ;
913using NDceRpc ;
1014using NDceRpc . Microsoft . Interop ;
1115using 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
1817namespace 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