API Reference
DirectoryObjectHelper
Provides strongly typed single-object read and property-update operations for user, group, computer, and OU objects.
Inheritance
- Object
- DirectoryObjectHelper
Constructors
public DirectoryObjectHelper(Func<DirectoryManagedObjectType, String, String, IReadOnlyList<String>, DirectoryObjectSnapshot> getObject = null, Func<DirectoryManagedObjectType, String, DirectoryObjectUpdate, String, DirectoryMutationResult> setObject = null, Func<String, Int32, GroupParentResult> resolveUserParentGroups = null, Func<String, Int32, GroupMembershipResult> resolveGroupMembers = null, Func<IReadOnlyList<String>> enumerateForestDomains = null) #Initializes a new instance of the DirectoryObjectHelper class.
Parameters
- getObject System.Func{ADPlayground.DirectoryManagedObjectType,System.String,System.String,System.Collections.Generic.IReadOnlyList{System.String},ADPlayground.DirectoryObjectSnapshot} = null
- Optional getter override for testing.
- setObject System.Func{ADPlayground.DirectoryManagedObjectType,System.String,ADPlayground.DirectoryObjectUpdate,System.String,ADPlayground.DirectoryMutationResult} = null
- Optional setter override for testing.
- resolveUserParentGroups System.Func{System.String,System.Int32,ADPlayground.GroupParentResult} = null
- Optional recursive user-group resolver override for testing.
- resolveGroupMembers System.Func{System.String,System.Int32,ADPlayground.GroupMembershipResult} = null
- Optional recursive group-member resolver override for testing.
- enumerateForestDomains System.Func{System.Collections.Generic.IReadOnlyList{System.String}} = null
- Optional forest domain enumeration override for testing and advanced matching scenarios.
Methods
public IReadOnlyList<DirectoryObjectSnapshot> FindComputerMatches(String identity, IEnumerable<String> domainNames = null, IEnumerable<String> attributes = null, Boolean includeForestDomains = false) #IReadOnlyList<DirectoryObjectSnapshot>Finds computer objects by identity across one or more domains.
Parameters
- identity System.String
- Computer identity (sAMAccountName, dNSHostName, DN, name).
- domainNames System.Collections.Generic.IEnumerable{System.String} = null
- Optional explicit domain DNS names to search.
- attributes System.Collections.Generic.IEnumerable{System.String} = null
- Optional additional LDAP attributes.
- includeForestDomains System.Boolean = false
- When true and domainNames is not supplied, searches all domains returned by forest enumeration.
Returns
All matching computer snapshots across selected domains; empty when nothing matches.
public IReadOnlyList<DirectoryObjectSnapshot> FindGroupMatches(String identity, IEnumerable<String> domainNames = null, IEnumerable<String> attributes = null, Boolean includeForestDomains = false) #IReadOnlyList<DirectoryObjectSnapshot>Finds group objects by identity across one or more domains.
Parameters
- identity System.String
- Group identity (sAMAccountName, DN, mail, name).
- domainNames System.Collections.Generic.IEnumerable{System.String} = null
- Optional explicit domain DNS names to search.
- attributes System.Collections.Generic.IEnumerable{System.String} = null
- Optional additional LDAP attributes.
- includeForestDomains System.Boolean = false
- When true and domainNames is not supplied, searches all domains returned by forest enumeration.
Returns
All matching group snapshots across selected domains; empty when nothing matches.
public IReadOnlyList<DirectoryObjectSnapshot> FindOrganizationalUnitMatches(String identity, IEnumerable<String> domainNames = null, IEnumerable<String> attributes = null, Boolean includeForestDomains = false) #IReadOnlyList<DirectoryObjectSnapshot>Finds organizational unit objects by identity across one or more domains.
Parameters
- identity System.String
- OU identity (DN, ou, or name).
- domainNames System.Collections.Generic.IEnumerable{System.String} = null
- Optional explicit domain DNS names to search.
- attributes System.Collections.Generic.IEnumerable{System.String} = null
- Optional additional LDAP attributes.
- includeForestDomains System.Boolean = false
- When true and domainNames is not supplied, searches all domains returned by forest enumeration.
Returns
All matching organizational unit snapshots across selected domains; empty when nothing matches.
public IReadOnlyList<DirectoryObjectSnapshot> FindUserMatches(String identity, IEnumerable<String> domainNames = null, IEnumerable<String> attributes = null, Boolean includeForestDomains = false) #IReadOnlyList<DirectoryObjectSnapshot>Finds user objects by identity across one or more domains.
Parameters
- identity System.String
- User identity (sAMAccountName, UPN, DN, mail, name).
- domainNames System.Collections.Generic.IEnumerable{System.String} = null
- Optional explicit domain DNS names to search.
- attributes System.Collections.Generic.IEnumerable{System.String} = null
- Optional additional LDAP attributes.
- includeForestDomains System.Boolean = false
- When true and domainNames is not supplied, searches all domains returned by forest enumeration.
Returns
All matching user snapshots across selected domains; empty when nothing matches.
public DirectoryObjectSnapshot GetComputer(String identity, String domainName = null, IEnumerable<String> attributes = null) #DirectoryObjectSnapshotGets one computer object by identity.
Parameters
- identity System.String
- Computer identity (sAMAccountName, dNSHostName, DN, name).
- domainName System.String = null
- Optional domain DNS name. When omitted, this method resolves a single domain context from identity hints (DN, UPN suffix, down-level DOMAIN\name) and then falls back to current machine context.
- attributes System.Collections.Generic.IEnumerable{System.String} = null
- Optional additional LDAP attributes.
Returns
Typed computer snapshot.
public DirectoryObjectSnapshot GetGroup(String identity, String domainName = null, IEnumerable<String> attributes = null) #DirectoryObjectSnapshotGets one group object by identity.
Parameters
- identity System.String
- Group identity (sAMAccountName, DN, mail, name).
- domainName System.String = null
- Optional domain DNS name. When omitted, this method resolves a single domain context from identity hints (DN, UPN suffix, down-level DOMAIN\name) and then falls back to current machine context.
- attributes System.Collections.Generic.IEnumerable{System.String} = null
- Optional additional LDAP attributes.
Returns
Typed group snapshot.
public DirectoryGroupMembersSnapshot GetGroupMembers(String identity, String domainName = null, Boolean recursive = false, Int32 maxDepth = 256) #DirectoryGroupMembersSnapshotGets direct group members and, optionally, recursively resolved nested memberships.
Parameters
- identity System.String
- Group identity (sAMAccountName, DN, mail, name).
- domainName System.String = null
- Optional domain DNS name. When omitted, domain is inferred from identity hints before falling back to current machine context.
- recursive System.Boolean = false
- When set, resolves recursive members via membership resolver.
- maxDepth System.Int32 = 256
- Maximum recursion depth used when resolving recursive members.
Returns
Typed group-membership snapshot.
public DirectoryObjectSnapshot GetOrganizationalUnit(String identity, String domainName = null, IEnumerable<String> attributes = null) #DirectoryObjectSnapshotGets one organizational unit object by identity.
Parameters
- identity System.String
- OU identity (DN, ou, or name).
- domainName System.String = null
- Optional domain DNS name. When omitted, this method resolves a single domain context from identity hints (primarily DN) and then falls back to current machine context.
- attributes System.Collections.Generic.IEnumerable{System.String} = null
- Optional additional LDAP attributes.
Returns
Typed organizational unit snapshot.
public static IReadOnlyList<String> GetReadOnlyAttributeDenylist() #IReadOnlyList<String>Gets the read-only LDAP attribute denylist enforced by directory object write operations.
Returns
Canonical read-only attribute names sorted alphabetically.
public DirectoryObjectSnapshot GetUser(String identity, String domainName = null, IEnumerable<String> attributes = null) #DirectoryObjectSnapshotGets one user object by identity.
Parameters
- identity System.String
- User identity (sAMAccountName, UPN, DN, mail, name).
- domainName System.String = null
- Optional domain DNS name. When omitted, this method resolves a single domain context from identity hints (DN, UPN suffix, down-level DOMAIN\name) and then falls back to current machine context.
- attributes System.Collections.Generic.IEnumerable{System.String} = null
- Optional additional LDAP attributes.
Returns
Typed user snapshot.
public DirectoryUserGroupsSnapshot GetUserGroups(String identity, String domainName = null, Boolean recursive = false, Int32 maxDepth = 256) #DirectoryUserGroupsSnapshotGets direct user group memberships and, optionally, recursive parent groups.
Parameters
- identity System.String
- User identity (sAMAccountName, UPN, DN, mail, name).
- domainName System.String = null
- Optional domain DNS name. When omitted, domain is inferred from identity hints before falling back to current machine context.
- recursive System.Boolean = false
- When set, resolves recursive parent groups via membership resolver.
- maxDepth System.Int32 = 256
- Maximum recursion depth used when resolving recursive groups.
Returns
Typed user-group membership snapshot.
public DirectoryMutationResult SetComputer(String identity, DirectoryObjectUpdate update, String domainName = null) #DirectoryMutationResultUpdates a computer object.
Parameters
- identity System.String
- Computer identity (sAMAccountName, dNSHostName, DN, name).
- update ADPlayground.DirectoryObjectUpdate
- Typed and custom attribute update definition.
- domainName System.String = null
- Optional domain DNS name. When omitted, domain is inferred from identity hints before falling back to current machine context.
Returns
Mutation result details.
public DirectoryMutationResult SetGroup(String identity, DirectoryObjectUpdate update, String domainName = null) #DirectoryMutationResultUpdates a group object.
Parameters
- identity System.String
- Group identity (sAMAccountName, DN, mail, name).
- update ADPlayground.DirectoryObjectUpdate
- Typed and custom attribute update definition.
- domainName System.String = null
- Optional domain DNS name. When omitted, domain is inferred from identity hints before falling back to current machine context.
Returns
Mutation result details.
public DirectoryMutationResult SetOrganizationalUnit(String identity, DirectoryObjectUpdate update, String domainName = null) #DirectoryMutationResultUpdates an organizational unit object.
Parameters
- identity System.String
- OU identity (DN, ou, or name).
- update ADPlayground.DirectoryObjectUpdate
- Typed and custom attribute update definition.
- domainName System.String = null
- Optional domain DNS name. When omitted, domain is inferred from identity hints before falling back to current machine context.
Returns
Mutation result details.
public DirectoryMutationResult SetUser(String identity, DirectoryObjectUpdate update, String domainName = null) #DirectoryMutationResultUpdates a user object.
Parameters
- identity System.String
- User identity (sAMAccountName, UPN, DN, mail, name).
- update ADPlayground.DirectoryObjectUpdate
- Typed and custom attribute update definition.
- domainName System.String = null
- Optional domain DNS name. When omitted, domain is inferred from identity hints before falling back to current machine context.
Returns
Mutation result details.