private bool GetADAccountAuthorizationGroupProcessCSRoutine() { this._partitionPath = this._cmdletParameters["Partition"] as string; this._identityADAccount = this._cmdletParameters["Identity"] as ADAccount; base.SetPipelinedSessionInfo(this._identityADAccount.SessionInfo); CmdletSessionInfo cmdletSessionInfo = base.GetCmdletSessionInfo(); ADAccountFactory <ADAccount> aDAccountFactory = new ADAccountFactory <ADAccount>(); aDAccountFactory.SetCmdletSessionInfo(cmdletSessionInfo); ADObject directoryObjectFromIdentity = aDAccountFactory.GetDirectoryObjectFromIdentity(this._identityADAccount, cmdletSessionInfo.DefaultPartitionPath); using (ADAccountManagement aDAccountManagement = new ADAccountManagement(cmdletSessionInfo.ADSessionInfo)) { ADGroup[] authorizationGroups = aDAccountManagement.GetAuthorizationGroups(cmdletSessionInfo.DefaultPartitionPath, directoryObjectFromIdentity.DistinguishedName); ADGroup[] aDGroupArray = authorizationGroups; for (int i = 0; i < (int)aDGroupArray.Length; i++) { ADGroup aDGroup = aDGroupArray[i]; base.WriteObject(aDGroup); } } return(true); }
private bool GetADAcctResPrpProcessCSRoutine() { ADResultantPasswordReplicationPolicy aDResultantPasswordReplicationPolicy = ADResultantPasswordReplicationPolicy.DenyExplicit; int?value; this._partitionPath = this._cmdletParameters["Partition"] as string; this._identityADAccount = this._cmdletParameters["Identity"] as ADAccount; this._targetDCAccount = this._cmdletParameters["DomainController"] as ADDomainController; base.SetPipelinedSessionInfo(this._identityADAccount.SessionInfo); CmdletSessionInfo cmdletSessionInfo = base.GetCmdletSessionInfo(); if (cmdletSessionInfo.ADRootDSE.IsWindows2008AndAbove()) { if (!cmdletSessionInfo.ADRootDSE.IsWritable()) { object[] dNSHostName = new object[1]; dNSHostName[0] = cmdletSessionInfo.ADRootDSE.DNSHostName; base.WriteWarning(string.Format(CultureInfo.CurrentCulture, StringResources.WarningResultantPRPNotAccurateOnRODC, dNSHostName)); } ADDomainControllerFactory <ADDomainController> aDDomainControllerFactory = new ADDomainControllerFactory <ADDomainController>(); aDDomainControllerFactory.SetCmdletSessionInfo(cmdletSessionInfo); ADAccountFactory <ADAccount> aDAccountFactory = new ADAccountFactory <ADAccount>(); aDAccountFactory.SetCmdletSessionInfo(cmdletSessionInfo); ADObject directoryObjectFromIdentity = aDDomainControllerFactory.GetDirectoryObjectFromIdentity(this._targetDCAccount, cmdletSessionInfo.DefaultPartitionPath); ADObject aDObject = aDAccountFactory.GetDirectoryObjectFromIdentity(this._identityADAccount, cmdletSessionInfo.DefaultPartitionPath); ADObjectSearcher distinguishedName = SearchUtility.BuildSearcher(cmdletSessionInfo.ADSessionInfo, directoryObjectFromIdentity.DistinguishedName, ADSearchScope.Base); using (distinguishedName) { distinguishedName.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*"); distinguishedName.Properties.Add("msDS-IsUserCachableAtRodc"); distinguishedName.InputDN = aDObject.DistinguishedName; ADObject aDObject1 = distinguishedName.FindOne(); if (aDObject1["msDS-IsUserCachableAtRodc"] == null) { int?nullable = null; value = nullable; } else { value = (int?)aDObject1["msDS-IsUserCachableAtRodc"].Value; } int?nullable1 = value; if (nullable1.HasValue) { if (!Utils.TryParseEnum <ADResultantPasswordReplicationPolicy>(nullable1.ToString(), out aDResultantPasswordReplicationPolicy)) { DebugLogger.LogInfo("GetADAccountResultantPasswordReplicationPolicy", string.Format("Error parsing resultant prp: {0} for account {1} on RODC {2}", aDResultantPasswordReplicationPolicy, aDObject.DistinguishedName, directoryObjectFromIdentity.DistinguishedName)); base.WriteObject(ADResultantPasswordReplicationPolicy.Unknown); } else { base.WriteObject(aDResultantPasswordReplicationPolicy); } } else { base.WriteObject(ADResultantPasswordReplicationPolicy.Unknown); } } return(true); } else { base.WriteError(new ErrorRecord(new ArgumentException(StringResources.ErrorResultantPRPSpecifyWindows2008OrAbove), "GetADAccountResultantPasswordReplicationPolicy:ProcessRecord", ErrorCategory.InvalidData, null)); return(false); } }