API Reference
ActiveDirectoryDataServices
Provides methods for querying computer accounts by last logon time.
Inheritance
- Object
- ActiveDirectoryDataServices
Constructors
public ActiveDirectoryDataServices() #Initializes a new instance of the ActiveDirectoryDataServices class.
Methods
public static String[] CombineComputerAttributes(ComputerProperties set, IEnumerable<String> additionalAttributes) #String[]Combines the standard computer attribute set with additional attributes, removing duplicates.
Parameters
- set ADPlayground.Helpers.ComputerProperties
- Standard computer attribute set.
- additionalAttributes System.Collections.Generic.IEnumerable{System.String}
- Additional attributes to include.
Returns
Combined list of attributes.
public static String CombineFilters(String baseFilter, String additionalFilter) #StringCombines a base LDAP filter with an additional filter using an AND expression.
Parameters
- baseFilter System.String
- Base LDAP filter.
- additionalFilter System.String
- Additional LDAP filter to AND with the base filter.
Returns
Combined LDAP filter.
public static String[] CombineGroupAttributes(GroupProperties set, IEnumerable<String> additionalAttributes, Boolean includeMembers) #String[]Combines the standard group attribute set with additional attributes, removing duplicates.
Parameters
- set ADPlayground.Helpers.GroupProperties
- Standard group attribute set.
- additionalAttributes System.Collections.Generic.IEnumerable{System.String}
- Additional attributes to include.
- includeMembers System.Boolean
- Whether to include the member attribute.
Returns
Combined list of attributes.
public static String[] CombineUserAttributes(UserProperties set, IEnumerable<String> additionalAttributes) #String[]Combines the standard user attribute set with additional attributes, removing duplicates.
Parameters
- set ADPlayground.Helpers.UserProperties
- Standard user attribute set.
- additionalAttributes System.Collections.Generic.IEnumerable{System.String}
- Additional attributes to include.
Returns
Combined list of attributes.
public IEnumerable<AdminAccountInfo> GetAdminAccounts(String domainName, String ouDistinguishedName = null) #IEnumerable<AdminAccountInfo>Retrieves comprehensive accounts with adminCount=1 from the specified domain.
Parameters
- domainName System.String
- Domain to query.
- ouDistinguishedName System.String = null
- Optional OU distinguished name.
public Task<IEnumerable<AdminAccountInfo>> GetAdminAccountsAsync(String domainName, String ouDistinguishedName = null, CancellationToken cancellationToken = null) #Task<IEnumerable<AdminAccountInfo>>Asynchronously retrieves comprehensive accounts with adminCount=1 from the specified domain.
Parameters
- domainName System.String
- ouDistinguishedName System.String = null
- cancellationToken System.Threading.CancellationToken = null
public IEnumerable<AdminAccountInfo> GetComprehensiveAdminAccounts(String domainName, String forestName = null, String ouDistinguishedName = null, Int32 maxLogonDays = 90, Int32 maxPasswordDays = 365, Boolean includeDisabledAccounts = true, Int32 degreeOfParallelism = 4) #IEnumerable<AdminAccountInfo>Retrieves comprehensive admin account information with configurable filtering.
Parameters
- domainName System.String
- forestName System.String = null
- ouDistinguishedName System.String = null
- maxLogonDays System.Int32 = 90
- maxPasswordDays System.Int32 = 365
- includeDisabledAccounts System.Boolean = true
- degreeOfParallelism System.Int32 = 4
public static Task<IEnumerable<AdminAccountInfo>> GetComprehensiveAdminAccountsAsync(String domainName = null, String forestName = null, String ouDistinguishedName = null, Int32 maxInactiveLogonDays = 90, Int32 maxPasswordAgeDays = 365, Boolean includeDisabledAccounts = true, CancellationToken cancellationToken = null) #Task<IEnumerable<AdminAccountInfo>>Gets comprehensive admin account information across domains.
Parameters
- domainName System.String = null
- forestName System.String = null
- ouDistinguishedName System.String = null
- maxInactiveLogonDays System.Int32 = 90
- maxPasswordAgeDays System.Int32 = 365
- includeDisabledAccounts System.Boolean = true
- cancellationToken System.Threading.CancellationToken = null
public IEnumerable<InactiveComputerInfo> GetInactiveComputerAccounts(String domainName, Int32 gracePeriodDays, String forestName = null) #IEnumerable<InactiveComputerInfo>Returns computer accounts that have not logged on within the specified number of days.
Parameters
- domainName System.String
- Domain to query. When null or empty all domains in the current or specified forest are scanned.
- gracePeriodDays System.Int32
- Number of days of allowed inactivity.
- forestName System.String = null
- Optional forest to target when domainName is not specified.
public Task<IEnumerable<InactiveComputerInfo>> GetInactiveComputerAccountsAsync(String domainName, Int32 gracePeriodDays, String forestName = null, CancellationToken cancellationToken = null) #Task<IEnumerable<InactiveComputerInfo>>Asynchronously returns computer accounts that have not logged on within the specified number of days.
Parameters
- domainName System.String
- Domain to query. When null or empty all domains in the current or specified forest are scanned.
- gracePeriodDays System.Int32
- Number of days of allowed inactivity.
- forestName System.String = null
- Optional forest to target when domainName is not specified.
- cancellationToken System.Threading.CancellationToken = null
- Token used to cancel the operation.
public IEnumerable<AdminAccountInfo> GetInactivePrivilegedAccounts(String domainName, DateTime inactiveSince, String forestName = null, String ouDistinguishedName = null) #IEnumerable<AdminAccountInfo>Returns privileged accounts that have been inactive since the provided UTC threshold.
Parameters
- domainName System.String
- inactiveSince System.DateTime
- forestName System.String = null
- ouDistinguishedName System.String = null
public Task<IEnumerable<AdminAccountInfo>> GetInactivePrivilegedAccountsAsync(String domainName, DateTime inactiveSince, String forestName = null, String ouDistinguishedName = null, CancellationToken cancellationToken = null) #Task<IEnumerable<AdminAccountInfo>>Asynchronously returns privileged accounts that have been inactive since the provided UTC threshold.
Parameters
- domainName System.String
- inactiveSince System.DateTime
- forestName System.String = null
- ouDistinguishedName System.String = null
- cancellationToken System.Threading.CancellationToken = null
public Void GetInformation(String forestName = "", String[] includeDomains = null, String[] excludeDomains = null, String[] includeDomainController = null, String[] excludeDomainController = null, Boolean preferWritable = false, Boolean skipRODC = false) #VoidPopulates information about the forest and its domains.
Parameters
- forestName System.String = ""
- Optional forest name to query. When empty the current forest is used.
- includeDomains System.String[] = null
- Specific domains to include when not querying the whole forest.
- excludeDomains System.String[] = null
- Domains to exclude from discovery.
- includeDomainController System.String[] = null
- Domain controllers to include when discovering.
- excludeDomainController System.String[] = null
- Domain controllers to exclude from discovery.
- preferWritable System.Boolean = false
- Set to true to prefer writable domain controllers.
- skipRODC System.Boolean = false
- Set to true to skip read-only domain controllers.
public IEnumerable<ComputerAccountInfo> GetOrphanedComputerAccounts(Int32 maxInactiveDays, Boolean includeDisabled = false, String domainName = null, String forestName = null, Int32 degreeOfParallelism = 4) #IEnumerable<ComputerAccountInfo>Returns computer accounts that have not logged on within the specified number of days.
Parameters
- maxInactiveDays System.Int32
- Maximum allowed inactivity in days.
- includeDisabled System.Boolean = false
- Whether to include disabled computer accounts.
- domainName System.String = null
- Optional domain to query. When null queries all domains.
- forestName System.String = null
- Optional forest to target when domainName is not specified.
- degreeOfParallelism System.Int32 = 4
- Maximum parallel domain queries.
Returns
Collection of orphaned computer accounts.
public List<ReplicationStatusInfo> GetReplicationStatus(String forestName) #List<ReplicationStatusInfo>Retrieves replication status information for the specified forest.
Parameters
- forestName System.String
- Name of the forest to query.
Returns
A list of replication status details.
public List<ReplicationStatusReport> GetReplicationStatusReport(String forestName) #List<ReplicationStatusReport>Builds a detailed replication status report.
Parameters
- forestName System.String
- Name of the forest.
Returns
A list of status report entries.
public String GetReplicationStatusReportJson(String forestName) #StringCreates a JSON representation of the replication status report.
Parameters
- forestName System.String
- Name of the forest.
Returns
JSON string with the status report.
public IEnumerable<ServiceAccountInfo> GetServiceAccounts(String domainName, String ouDistinguishedName = null) #IEnumerable<ServiceAccountInfo>Retrieves accounts that have one or more service principal names set.
Parameters
- domainName System.String
- ouDistinguishedName System.String = null
public Task<IEnumerable<ServiceAccountInfo>> GetServiceAccountsAsync(String domainName, String ouDistinguishedName = null, CancellationToken cancellationToken = null) #Task<IEnumerable<ServiceAccountInfo>>Asynchronously retrieves accounts that have one or more service principal names set.
Parameters
- domainName System.String
- ouDistinguishedName System.String = null
- cancellationToken System.Threading.CancellationToken = null
public ImmutableArray<SiteInfo> GetSitesAndSubnets() #ImmutableArray<SiteInfo>Retrieves all sites in the current forest and their associated subnets.
Returns
An immutable collection of SiteInfo objects.
public IEnumerable<AdminAccountInfo> GetStaleAdminAccounts(String domainName, Int32 maxInactiveDays, String forestName = null, String ouDistinguishedName = null, Int32 degreeOfParallelism = 4) #IEnumerable<AdminAccountInfo>Returns admin accounts that have not logged in for more than maxInactiveDays days.
Parameters
- domainName System.String
- maxInactiveDays System.Int32
- forestName System.String = null
- ouDistinguishedName System.String = null
- degreeOfParallelism System.Int32 = 4
public Task<IEnumerable<AdminAccountInfo>> GetStaleAdminAccountsAsync(String domainName, Int32 maxInactiveDays, String forestName = null, String ouDistinguishedName = null, Int32 degreeOfParallelism = 4, CancellationToken cancellationToken = null) #Task<IEnumerable<AdminAccountInfo>>Asynchronously returns admin accounts that have not logged in for more than the specified days.
Parameters
- domainName System.String
- maxInactiveDays System.Int32
- forestName System.String = null
- ouDistinguishedName System.String = null
- degreeOfParallelism System.Int32 = 4
- cancellationToken System.Threading.CancellationToken = null
public IEnumerable<ServiceAccountInfo> GetStaleServiceAccounts(String domainName, Int32 maxPasswordAgeDays, Int32 maxInactiveDays, String forestName = null, String ouDistinguishedName = null, Int32 degreeOfParallelism = 4) #IEnumerable<ServiceAccountInfo>Returns service accounts exceeding password or inactivity thresholds.
Parameters
- domainName System.String
- maxPasswordAgeDays System.Int32
- maxInactiveDays System.Int32
- forestName System.String = null
- ouDistinguishedName System.String = null
- degreeOfParallelism System.Int32 = 4
public Task<IEnumerable<ServiceAccountInfo>> GetStaleServiceAccountsAsync(String domainName, Int32 maxPasswordAgeDays, Int32 maxInactiveDays, String forestName = null, String ouDistinguishedName = null, Int32 degreeOfParallelism = 4, CancellationToken cancellationToken = null) #Task<IEnumerable<ServiceAccountInfo>>Asynchronously returns service accounts exceeding password or inactivity thresholds.
Parameters
- domainName System.String
- maxPasswordAgeDays System.Int32
- maxInactiveDays System.Int32
- forestName System.String = null
- ouDistinguishedName System.String = null
- degreeOfParallelism System.Int32 = 4
- cancellationToken System.Threading.CancellationToken = null
IsReadOnly(System.String DomainController) #Check if a domain controller is read-only
Parameters
- DomainController System.String
IsReadOnly(System.DirectoryServices.ActiveDirectory.DomainController dc) #Check if a domain controller is read-only
Parameters
- dc System.DirectoryServices.ActiveDirectory.DomainController
IsWritable(System.DirectoryServices.ActiveDirectory.DomainController dc) #Determines whether the specified domain controller accepts write operations.
Parameters
- dc System.DirectoryServices.ActiveDirectory.DomainController
- Domain controller to validate.
Returns
true when writable; otherwise false.
public Boolean TryGetDomainFunctionalLevel(String domainName, out DomainMode level) #BooleanAttempts to retrieve the functional level for the specified domain from the in-memory overview cache.
Parameters
- domainName System.String
- DNS domain name.
- level System.DirectoryServices.ActiveDirectory.DomainMode@
- Resolved functional level on success; Unknown on failure.
Returns
True when the level was available in the cache; otherwise false.
public Boolean TryGetForestFunctionalLevel(out ForestMode level) #BooleanAttempts to retrieve the forest functional level from the in-memory overview cache.
Parameters
- level System.DirectoryServices.ActiveDirectory.ForestMode@
- Resolved forest functional level; Unknown when not available.
Returns
True when the level was available in the cache; otherwise false.
Inherited Methods
Properties
public ForestMode ForestFunctionalLevel { get; set; } #Gets the forest functional level discovered during enumeration.
public Int32 GlobalCatalogCount { get; set; } #Gets the total number of global catalogs discovered.
public static ActiveDirectoryDataServices Default { get; } #Gets a shared instance of ActiveDirectoryDataServices used for convenience queries.
Fields
_default #Lazily instantiated default instance used by the Default property.
public Dictionary<String, DomainController> DomainControllers #Gets domain controllers indexed by domain name.
public List<String> Domains #Gets the list of discovered domain names.
public List<DomainControllerInfo> ForestDomainControllers #Gets domain controllers discovered in the forest.
public Dictionary<String, List<DomainControllerInfo>> DomainControllerDetails #Gets detailed metadata for domain controllers by domain.
public List<DomainControllerInfo> ForestDomainControllerDetails #Gets detailed metadata for all discovered domain controllers in the forest.
public String ForestName #Gets the name of the current forest.
public List<Domain> FullDomains #Gets the collection of discovered domains as Domain objects.
public Forest FullForest #Gets the discovered forest object.
public Dictionary<String, Int32> DomainControllerCountsByDomain #Gets counts of discovered domain controllers grouped by domain name.
public Dictionary<String, DomainMode> DomainFunctionalLevels #Gets functional level per discovered domain.
public Dictionary<String, DomainController> QueryServers #Gets preferred query servers indexed by domain name.
public String RootDomainName #Gets the name of the root domain.