/// <summary> /// Adds the group property. /// </summary> /// <param name="groupPrincipal">The group principal.</param> /// <param name="property">The property.</param> /// <param name="result">The result.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> /// TODO Edit XML Comment Template for AddGroupProperty private static bool AddGroupProperty( GroupPrincipal groupPrincipal, ActiveDirectoryProperty property, dynamic result) { var propertyMapping = new ActiveDirectoryPropertyMapping { [ActiveDirectoryProperty.GroupContext] = () => { result.GroupContext = groupPrincipal.Context; }, [ActiveDirectoryProperty.GroupContextType] = () => { result.GroupContextType = groupPrincipal.ContextType; }, [ActiveDirectoryProperty.GroupDescription] = () => { result.GroupDescription = groupPrincipal.Description; }, [ActiveDirectoryProperty.GroupDisplayName] = () => { result.GroupDisplayName = groupPrincipal.DisplayName; }, [ActiveDirectoryProperty.GroupDistinguishedName] = () => { result.GroupDistinguishedName = groupPrincipal.DistinguishedName; }, [ActiveDirectoryProperty.GroupGuid] = () => { result.GroupGuid = groupPrincipal.Guid; }, [ActiveDirectoryProperty.GroupIsSecurityGroup] = () => { result.GroupIsSecurityGroup = groupPrincipal.IsSecurityGroup; }, [ActiveDirectoryProperty.GroupManagedByDistinguishedName] = () => { result.GroupManagedByDistinguishedName = groupPrincipal .GetManagedByDistinguishedName(); }, [ActiveDirectoryProperty.GroupManagedByName] = () => { result.GroupManagedByName = groupPrincipal.GetManagedByName(); }, [ActiveDirectoryProperty.GroupName] = () => { result.GroupName = groupPrincipal.Name; }, [ActiveDirectoryProperty.GroupSamAccountName] = () => { result.GroupSamAccountName = groupPrincipal.SamAccountName; }, [ActiveDirectoryProperty.GroupScope] = () => { result.GroupScope = groupPrincipal.GroupScope; }, [ActiveDirectoryProperty.GroupSid] = () => { result.GroupSid = groupPrincipal.Sid; }, [ActiveDirectoryProperty.GroupStructuralObjectClass] = () => { result.GroupStructuralObjectClass = groupPrincipal.StructuralObjectClass; }, [ActiveDirectoryProperty.GroupUserPrincipalName] = () => { result.GroupUserPrincipalName = groupPrincipal.UserPrincipalName; }, [ActiveDirectoryProperty.GroupMembers] = () => { result.GroupMembers = groupPrincipal.Members; } }; if (!propertyMapping.ContainsKey(property)) { return(false); } propertyMapping[property](); return(true); }
/// <summary> /// Adds the user property. /// </summary> /// <param name="userPrincipal">The user principal.</param> /// <param name="property">The property.</param> /// <param name="result">The result.</param> /// TODO Edit XML Comment Template for AddUserProperty private static void AddUserProperty( UserPrincipal userPrincipal, ActiveDirectoryProperty property, dynamic result) { var propertyMapping = new ActiveDirectoryPropertyMapping { [ActiveDirectoryProperty.UserUserAccountControl] = () => { result.UserAccountControl = userPrincipal.GetUserAccountControl(); }, [ActiveDirectoryProperty.UserAccountExpirationDate] = () => { result.UserAccountExpirationDate = userPrincipal.AccountExpirationDate; }, [ActiveDirectoryProperty.UserAccountLockoutTime] = () => { result.UserAccountLockoutTime = userPrincipal.AccountLockoutTime; }, [ActiveDirectoryProperty .UserAllowReversiblePasswordEncryption] = () => { result.UserAllowReversiblePasswordEncryption = userPrincipal .AllowReversiblePasswordEncryption; }, [ActiveDirectoryProperty.UserAssistant] = () => { result.UserAssistant = userPrincipal.GetAssistant(); }, [ActiveDirectoryProperty.UserBadLogonCount] = () => { result.UserBadLogonCount = userPrincipal.BadLogonCount; }, [ActiveDirectoryProperty.UserCertificates] = () => { result.UserCertificates = userPrincipal.Certificates; }, [ActiveDirectoryProperty.UserCity] = () => { result.UserCity = userPrincipal.GetCity(); }, [ActiveDirectoryProperty.UserComment] = () => { result.UserComment = userPrincipal.GetComment(); }, [ActiveDirectoryProperty.UserCompany] = () => { result.UserCompany = userPrincipal.GetCompany(); }, [ActiveDirectoryProperty.UserContext] = () => { result.UserContext = userPrincipal.Context; }, [ActiveDirectoryProperty.UserContextType] = () => { result.UserContextType = userPrincipal.ContextType; }, [ActiveDirectoryProperty.UserCountry] = () => { result.UserCountry = userPrincipal.GetCountry(); }, [ActiveDirectoryProperty.UserDelegationPermitted] = () => { result.UserDelegationPermitted = userPrincipal.DelegationPermitted; }, [ActiveDirectoryProperty.UserDepartment] = () => { result.UserDepartment = userPrincipal.GetDepartment(); }, [ActiveDirectoryProperty.UserDescription] = () => { result.UserDescription = userPrincipal.Description; }, [ActiveDirectoryProperty.UserDisplayName] = () => { result.UserDisplayName = userPrincipal.DisplayName; }, [ActiveDirectoryProperty.UserDistinguishedName] = () => { result.UserDistinguishedName = userPrincipal.DistinguishedName; }, [ActiveDirectoryProperty.UserDivision] = () => { result.UserDivision = userPrincipal.GetDivision(); }, [ActiveDirectoryProperty.UserEmailAddress] = () => { result.UserEmailAddress = userPrincipal.EmailAddress; }, [ActiveDirectoryProperty.UserEmployeeId] = () => { result.UserEmployeeId = userPrincipal.EmployeeId; }, [ActiveDirectoryProperty.UserEnabled] = () => { result.UserEnabled = userPrincipal.Enabled; }, [ActiveDirectoryProperty.UserFax] = () => { result.UserFax = userPrincipal.GetFax(); }, [ActiveDirectoryProperty.UserSuffix] = () => { result.UserSuffix = userPrincipal.GetSuffix(); }, [ActiveDirectoryProperty.UserGivenName] = () => { result.UserGivenName = userPrincipal.GivenName; }, [ActiveDirectoryProperty.UserGuid] = () => { result.UserGuid = userPrincipal.Guid; }, [ActiveDirectoryProperty.UserEmployeeNumber] = () => { result.EmployeeNumber = userPrincipal.GetEmployeeNumber(); }, [ActiveDirectoryProperty.UserEmployeeNumberHash] = () => { result.EmployeeNumberHash = userPrincipal.GetEmployeeNumberHash(); }, [ActiveDirectoryProperty.UserHomeAddress] = () => { result.UserHomeAddress = userPrincipal.GetHomeAddress(); }, [ActiveDirectoryProperty.UserHomeDirectory] = () => { result.UserHomeDirectory = userPrincipal.HomeDirectory; }, [ActiveDirectoryProperty.UserHomeDrive] = () => { result.UserHomeDrive = userPrincipal.HomeDrive; }, [ActiveDirectoryProperty.UserHomePhone] = () => { result.UserHomePhone = userPrincipal.GetHomePhone(); }, [ActiveDirectoryProperty.UserInitials] = () => { result.UserInitials = userPrincipal.GetInitials(); }, [ActiveDirectoryProperty.UserIsAccountLockedOut] = () => { result.UserIsAccountLockedOut = userPrincipal.IsAccountLockedOut(); }, [ActiveDirectoryProperty.UserIsActive] = () => { result.UserIsActive = userPrincipal.IsActive(); }, [ActiveDirectoryProperty.UserLastBadPasswordAttempt] = () => { result.UserLastBadPasswordAttempt = userPrincipal.LastBadPasswordAttempt; }, [ActiveDirectoryProperty.UserLastLogon] = () => { result.UserLastLogon = userPrincipal.LastLogon; }, [ActiveDirectoryProperty.UserLastPasswordSet] = () => { result.UserLastPasswordSet = userPrincipal.LastPasswordSet; }, [ActiveDirectoryProperty.ManagerDistinguishedName] = () => { result.ManagerDistinguishedName = userPrincipal.GetManagerDistinguishedName(); }, [ActiveDirectoryProperty.ManagerName] = () => { result.ManagerName = userPrincipal.GetManagerName(); }, [ActiveDirectoryProperty.UserMiddleName] = () => { result.UserMiddleName = userPrincipal.MiddleName; }, [ActiveDirectoryProperty.UserMobile] = () => { result.UserMobile = userPrincipal.GetMobile(); }, [ActiveDirectoryProperty.UserName] = () => { result.UserName = userPrincipal.Name; }, [ActiveDirectoryProperty.UserNotes] = () => { result.UserNotes = userPrincipal.GetNotes(); }, [ActiveDirectoryProperty.UserPager] = () => { result.UserPager = userPrincipal.GetPager(); }, [ActiveDirectoryProperty.UserPasswordNeverExpires] = () => { result.UserPasswordNeverExpires = userPrincipal.PasswordNeverExpires; }, [ActiveDirectoryProperty.UserPasswordNotRequired] = () => { result.UserPasswordNotRequired = userPrincipal.PasswordNotRequired; }, [ActiveDirectoryProperty.UserPermittedLogonTimes] = () => { result.UserPermittedLogonTimes = userPrincipal.PermittedLogonTimes; }, [ActiveDirectoryProperty.UserPermittedWorkstations] = () => { result.UserPermittedWorkstations = userPrincipal.PermittedWorkstations; }, [ActiveDirectoryProperty.UserSamAccountName] = () => { result.UserSamAccountName = userPrincipal.SamAccountName; }, [ActiveDirectoryProperty.UserScriptPath] = () => { result.UserScriptPath = userPrincipal.ScriptPath; }, [ActiveDirectoryProperty.UserSid] = () => { result.UserSid = userPrincipal.Sid; }, [ActiveDirectoryProperty.UserSip] = () => { result.UserSip = userPrincipal.GetSip(); }, [ActiveDirectoryProperty.UserSmartcardLogonRequired] = () => { result.UserSmartcardLogonRequired = userPrincipal.SmartcardLogonRequired; }, [ActiveDirectoryProperty.UserState] = () => { result.UserState = userPrincipal.GetState(); }, [ActiveDirectoryProperty.UserStreetAddress] = () => { result.UserStreetAddress = userPrincipal.GetStreetAddress(); }, [ActiveDirectoryProperty.UserStructuralObjectClass] = () => { result.UserStructuralObjectClass = userPrincipal.StructuralObjectClass; }, [ActiveDirectoryProperty.UserSurname] = () => { result.UserSurname = userPrincipal.Surname; }, [ActiveDirectoryProperty.UserTitle] = () => { result.UserTitle = userPrincipal.GetTitle(); }, [ActiveDirectoryProperty.UserCannotChangePassword] = () => { result.UserCannotChangePassword = userPrincipal.UserCannotChangePassword; }, [ActiveDirectoryProperty.UserUserPrincipalName] = () => { result.UserUserPrincipalName = userPrincipal.UserPrincipalName; }, [ActiveDirectoryProperty.UserVoiceTelephoneNumber] = () => { result.UserVoiceTelephoneNumber = userPrincipal.VoiceTelephoneNumber; }, [ActiveDirectoryProperty.UserVoip] = () => { result.UserVoip = userPrincipal.GetVoip(); } }; if (!propertyMapping.ContainsKey(property)) { return; } propertyMapping[property](); }
/// <summary> /// Adds the computer property. /// </summary> /// <param name="computerPrincipal">The computer principal.</param> /// <param name="property">The property.</param> /// <param name="result">The result.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> /// TODO Edit XML Comment Template for AddComputerProperty private static bool AddComputerProperty( ComputerPrincipal computerPrincipal, ActiveDirectoryProperty property, dynamic result) { var propertyMapping = new ActiveDirectoryPropertyMapping { [ActiveDirectoryProperty.ComputerAccountExpirationDate] = () => { result.ComputerAccountExpirationDate = computerPrincipal ?.AccountExpirationDate; }, [ActiveDirectoryProperty.ComputerAccountLockoutTime] = () => { result.ComputerAccountLockoutTime = computerPrincipal?.AccountLockoutTime; }, [ActiveDirectoryProperty .ComputerAllowReversiblePasswordEncryption] = () => { result.ComputerAllowReversiblePasswordEncryption = computerPrincipal?.AllowReversiblePasswordEncryption; }, [ActiveDirectoryProperty.ComputerBadLogonCount] = () => { result.ComputerBadLogonCount = computerPrincipal?.BadLogonCount; }, [ActiveDirectoryProperty.ComputerCertificates] = () => { result.ComputerCertificates = computerPrincipal?.Certificates; }, [ActiveDirectoryProperty.ComputerContext] = () => { result.ComputerContext = computerPrincipal?.Context; }, [ActiveDirectoryProperty.ComputerContextType] = () => { result.ComputerContextType = computerPrincipal?.ContextType; }, [ActiveDirectoryProperty.ComputerDelegationPermitted] = () => { result.ComputerDelegationPermitted = computerPrincipal?.DelegationPermitted; }, [ActiveDirectoryProperty.ComputerDescription] = () => { result.ComputerDescription = computerPrincipal?.Description; }, [ActiveDirectoryProperty.ComputerDisplayName] = () => { result.ComputerDisplayName = computerPrincipal?.DisplayName; }, [ActiveDirectoryProperty.ComputerDistinguishedName] = () => { result.ComputerDistinguishedName = computerPrincipal?.DistinguishedName; }, [ActiveDirectoryProperty.ComputerEnabled] = () => { result.ComputerEnabled = computerPrincipal?.Enabled; }, [ActiveDirectoryProperty.ComputerGuid] = () => { result.ComputerGuid = computerPrincipal?.Guid; }, [ActiveDirectoryProperty.ComputerHomeDirectory] = () => { result.ComputerHomeDirectory = computerPrincipal?.HomeDirectory; }, [ActiveDirectoryProperty.ComputerHomeDrive] = () => { result.ComputerHomeDrive = computerPrincipal?.HomeDrive; }, [ActiveDirectoryProperty.ComputerLastBadPasswordAttempt] = () => { result.ComputerLastBadPasswordAttempt = computerPrincipal ?.LastBadPasswordAttempt; }, [ActiveDirectoryProperty.ComputerLastLogon] = () => { result.ComputerLastLogon = computerPrincipal?.LastLogon; }, [ActiveDirectoryProperty.ComputerLastPasswordSet] = () => { result.LastPasswordSet = computerPrincipal?.LastPasswordSet; }, [ActiveDirectoryProperty.ComputerName] = () => { result.ComputerName = computerPrincipal?.Name; }, [ActiveDirectoryProperty.ComputerPasswordNeverExpires] = () => { result.ComputerPasswordNeverExpires = computerPrincipal?.PasswordNeverExpires; }, [ActiveDirectoryProperty.ComputerPasswordNotRequired] = () => { result.ComputerPasswordNotRequired = computerPrincipal?.PasswordNotRequired; }, [ActiveDirectoryProperty.ComputerPermittedLogonTimes] = () => { result.ComputerPermittedLogonTimes = computerPrincipal?.PermittedLogonTimes; }, [ActiveDirectoryProperty.ComputerPermittedWorkstations] = () => { result.ComputerPermittedWorkstations = computerPrincipal ?.PermittedWorkstations; }, [ActiveDirectoryProperty.ComputerSamAccountName] = () => { result.ComputerSamAccountName = computerPrincipal?.SamAccountName; }, [ActiveDirectoryProperty.ComputerScriptPath] = () => { result.ComputerScriptPath = computerPrincipal?.ScriptPath; }, [ActiveDirectoryProperty.ComputerServicePrincipalNames] = () => { result.ComputerServicecomputerPrincipalNames = computerPrincipal?.ServicePrincipalNames; }, [ActiveDirectoryProperty.ComputerSid] = () => { result.ComputerSid = computerPrincipal?.Sid; }, [ActiveDirectoryProperty.ComputerSmartcardLogonRequired] = () => { result.ComputerSmartcardLogonRequired = computerPrincipal ?.SmartcardLogonRequired; }, [ActiveDirectoryProperty.ComputerStructuralObjectClass] = () => { result.ComputerStructuralObjectClass = computerPrincipal ?.StructuralObjectClass; }, [ActiveDirectoryProperty.ComputerUserCannotChangePassword] = () => { result.ComputerUserCannotChangePassword = computerPrincipal ?.UserCannotChangePassword; }, [ActiveDirectoryProperty.ComputerUserPrincipalName] = () => { result.ComputerUsercomputerPrincipalName = computerPrincipal?.UserPrincipalName; } }; if (!propertyMapping.ContainsKey(property)) { return(false); } propertyMapping[property](); return(true); }