@@ -148,42 +148,26 @@ public async Task<UserProperties> ReadUserProperties(ISearchResultEntry entry)
148148 {
149149 var userProps = new UserProperties ( ) ;
150150 var props = GetCommonProps ( entry ) ;
151-
151+
152+ var uacFlags = ( UacFlags ) 0 ;
152153 var uac = entry . GetProperty ( LDAPProperties . UserAccountControl ) ;
153- bool enabled , trustedToAuth , sensitive , dontReqPreAuth , passwdNotReq , unconstrained , pwdNeverExpires ;
154154 if ( int . TryParse ( uac , out var flag ) )
155155 {
156- var flags = ( UacFlags ) flag ;
157- enabled = ( flags & UacFlags . AccountDisable ) == 0 ;
158- trustedToAuth = ( flags & UacFlags . TrustedToAuthForDelegation ) != 0 ;
159- sensitive = ( flags & UacFlags . NotDelegated ) != 0 ;
160- dontReqPreAuth = ( flags & UacFlags . DontReqPreauth ) != 0 ;
161- passwdNotReq = ( flags & UacFlags . PasswordNotRequired ) != 0 ;
162- unconstrained = ( flags & UacFlags . TrustedForDelegation ) != 0 ;
163- pwdNeverExpires = ( flags & UacFlags . DontExpirePassword ) != 0 ;
164- }
165- else
166- {
167- trustedToAuth = false ;
168- enabled = true ;
169- sensitive = false ;
170- dontReqPreAuth = false ;
171- passwdNotReq = false ;
172- unconstrained = false ;
173- pwdNeverExpires = false ;
156+ uacFlags = ( UacFlags ) flag ;
174157 }
158+
159+ props . Add ( "sensitive" , uacFlags . HasFlag ( UacFlags . NotDelegated ) ) ;
160+ props . Add ( "dontreqpreauth" , uacFlags . HasFlag ( UacFlags . DontReqPreauth ) ) ;
161+ props . Add ( "passwordnotreqd" , uacFlags . HasFlag ( UacFlags . PasswordNotRequired ) ) ;
162+ props . Add ( "unconstraineddelegation" , uacFlags . HasFlag ( UacFlags . TrustedForDelegation ) ) ;
163+ props . Add ( "pwdneverexpires" , uacFlags . HasFlag ( UacFlags . DontExpirePassword ) ) ;
164+ props . Add ( "enabled" , ! uacFlags . HasFlag ( UacFlags . AccountDisable ) ) ;
165+ props . Add ( "trustedtoauth" , uacFlags . HasFlag ( UacFlags . TrustedToAuthForDelegation ) ) ;
175166
176- props . Add ( "sensitive" , sensitive ) ;
177- props . Add ( "dontreqpreauth" , dontReqPreAuth ) ;
178- props . Add ( "passwordnotreqd" , passwdNotReq ) ;
179- props . Add ( "unconstraineddelegation" , unconstrained ) ;
180- props . Add ( "pwdneverexpires" , pwdNeverExpires ) ;
181- props . Add ( "enabled" , enabled ) ;
182- props . Add ( "trustedtoauth" , trustedToAuth ) ;
183167 var domain = Helpers . DistinguishedNameToDomain ( entry . DistinguishedName ) ;
184168
185169 var comps = new List < TypedPrincipal > ( ) ;
186- if ( trustedToAuth )
170+ if ( uacFlags . HasFlag ( UacFlags . TrustedToAuthForDelegation ) )
187171 {
188172 var delegates = entry . GetArrayProperty ( LDAPProperties . AllowedToDelegateTo ) ;
189173 props . Add ( "allowedtodelegate" , delegates ) ;
@@ -276,27 +260,23 @@ public async Task<ComputerProperties> ReadComputerProperties(ISearchResultEntry
276260 {
277261 var compProps = new ComputerProperties ( ) ;
278262 var props = GetCommonProps ( entry ) ;
279-
263+
264+ var flags = ( UacFlags ) 0 ;
280265 var uac = entry . GetProperty ( LDAPProperties . UserAccountControl ) ;
281- bool enabled , unconstrained , trustedToAuth ;
282266 if ( int . TryParse ( uac , out var flag ) )
283267 {
284- var flags = ( UacFlags ) flag ;
285- enabled = ( flags & UacFlags . AccountDisable ) == 0 ;
286- unconstrained = ( flags & UacFlags . TrustedForDelegation ) == UacFlags . TrustedForDelegation ;
287- trustedToAuth = ( flags & UacFlags . TrustedToAuthForDelegation ) != 0 ;
288- }
289- else
290- {
291- unconstrained = false ;
292- enabled = true ;
293- trustedToAuth = false ;
268+ flags = ( UacFlags ) flag ;
294269 }
270+
271+ props . Add ( "enabled" , ! flags . HasFlag ( UacFlags . AccountDisable ) ) ;
272+ props . Add ( "unconstraineddelegation" , flags . HasFlag ( UacFlags . TrustedForDelegation ) ) ;
273+ props . Add ( "trustedtoauth" , flags . HasFlag ( UacFlags . TrustedToAuthForDelegation ) ) ;
274+ props . Add ( "isdc" , flags . HasFlag ( UacFlags . ServerTrustAccount ) ) ;
295275
296276 var domain = Helpers . DistinguishedNameToDomain ( entry . DistinguishedName ) ;
297277
298278 var comps = new List < TypedPrincipal > ( ) ;
299- if ( trustedToAuth )
279+ if ( flags . HasFlag ( UacFlags . TrustedToAuthForDelegation ) )
300280 {
301281 var delegates = entry . GetArrayProperty ( LDAPProperties . AllowedToDelegateTo ) ;
302282 props . Add ( "allowedtodelegate" , delegates ) ;
@@ -332,15 +312,13 @@ public async Task<ComputerProperties> ReadComputerProperties(ISearchResultEntry
332312
333313 compProps . AllowedToAct = allowedToActPrincipals . ToArray ( ) ;
334314
335- props . Add ( "enabled" , enabled ) ;
336- props . Add ( "unconstraineddelegation" , unconstrained ) ;
337- props . Add ( "trustedtoauth" , trustedToAuth ) ;
338315 props . Add ( "lastlogon" , Helpers . ConvertFileTimeToUnixEpoch ( entry . GetProperty ( LDAPProperties . LastLogon ) ) ) ;
339316 props . Add ( "lastlogontimestamp" ,
340317 Helpers . ConvertFileTimeToUnixEpoch ( entry . GetProperty ( LDAPProperties . LastLogonTimestamp ) ) ) ;
341318 props . Add ( "pwdlastset" ,
342319 Helpers . ConvertFileTimeToUnixEpoch ( entry . GetProperty ( LDAPProperties . PasswordLastSet ) ) ) ;
343320 props . Add ( "serviceprincipalnames" , entry . GetArrayProperty ( LDAPProperties . ServicePrincipalNames ) ) ;
321+ props . Add ( "email" , entry . GetProperty ( LDAPProperties . Email ) ) ;
344322 var os = entry . GetProperty ( LDAPProperties . OperatingSystem ) ;
345323 var sp = entry . GetProperty ( LDAPProperties . ServicePack ) ;
346324
@@ -516,6 +494,16 @@ public static Dictionary<string, object> ReadCertTemplateProperties(ISearchResul
516494 nameFlags . HasFlag ( PKICertificateNameFlag . ENROLLEE_SUPPLIES_SUBJECT ) ) ;
517495 props . Add ( "subjectaltrequireupn" ,
518496 nameFlags . HasFlag ( PKICertificateNameFlag . SUBJECT_ALT_REQUIRE_UPN ) ) ;
497+ props . Add ( "subjectaltrequiredns" ,
498+ nameFlags . HasFlag ( PKICertificateNameFlag . SUBJECT_ALT_REQUIRE_DNS ) ) ;
499+ props . Add ( "subjectaltrequiredomaindns" ,
500+ nameFlags . HasFlag ( PKICertificateNameFlag . SUBJECT_ALT_REQUIRE_DOMAIN_DNS ) ) ;
501+ props . Add ( "subjectaltrequireemail" ,
502+ nameFlags . HasFlag ( PKICertificateNameFlag . SUBJECT_ALT_REQUIRE_EMAIL ) ) ;
503+ props . Add ( "subjectaltrequirespn" ,
504+ nameFlags . HasFlag ( PKICertificateNameFlag . SUBJECT_ALT_REQUIRE_SPN ) ) ;
505+ props . Add ( "subjectrequireemail" ,
506+ nameFlags . HasFlag ( PKICertificateNameFlag . SUBJECT_REQUIRE_EMAIL ) ) ;
519507 }
520508
521509 string [ ] ekus = entry . GetArrayProperty ( LDAPProperties . ExtendedKeyUsage ) ;
@@ -761,4 +749,4 @@ public class ComputerProperties
761749 public TypedPrincipal [ ] SidHistory { get ; set ; } = Array . Empty < TypedPrincipal > ( ) ;
762750 public TypedPrincipal [ ] DumpSMSAPassword { get ; set ; } = Array . Empty < TypedPrincipal > ( ) ;
763751 }
764- }
752+ }
0 commit comments