Ejemplo n.º 1
0
        private bool GetADGroupMemberProcessCSRoutine()
        {
            this._partitionPath   = this._cmdletParameters["Partition"] as string;
            this._identityADGroup = this._cmdletParameters["Identity"] as ADGroup;
            this._isRecursive     = this._cmdletParameters.GetSwitchParameterBooleanValue("Recursive");
            base.SetPipelinedSessionInfo(this._identityADGroup.SessionInfo);
            CmdletSessionInfo        cmdletSessionInfo = base.GetCmdletSessionInfo();
            ADGroupFactory <ADGroup> aDGroupFactory    = new ADGroupFactory <ADGroup>();

            aDGroupFactory.SetCmdletSessionInfo(cmdletSessionInfo);
            this.ValidateParameters();
            ADObject directoryObjectFromIdentity = aDGroupFactory.GetDirectoryObjectFromIdentity(this._identityADGroup, cmdletSessionInfo.DefaultPartitionPath);

            using (ADAccountManagement aDAccountManagement = new ADAccountManagement(cmdletSessionInfo.ADSessionInfo))
            {
                ADPrincipal[] groupMembers     = aDAccountManagement.GetGroupMembers(cmdletSessionInfo.DefaultPartitionPath, directoryObjectFromIdentity.DistinguishedName, this._isRecursive);
                ADPrincipal[] aDPrincipalArray = groupMembers;
                for (int i = 0; i < (int)aDPrincipalArray.Length; i++)
                {
                    ADPrincipal aDPrincipal = aDPrincipalArray[i];
                    base.WriteObject(aDPrincipal);
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        internal static void PerformSetPassword(string partitionDN, ADObject directoryObj, SecureString newPassword)
        {
            ADSessionInfo sessionInfo = directoryObj.SessionInfo;

            using (ADAccountManagement aDAccountManagement = new ADAccountManagement(sessionInfo))
            {
                IntPtr bSTR      = Marshal.SecureStringToBSTR(newPassword);
                string stringUni = Marshal.PtrToStringUni(bSTR);
                aDAccountManagement.SetPassword(partitionDN, directoryObj.DistinguishedName, stringUni);
            }
        }
Ejemplo n.º 3
0
        private bool GetGroupMembershipProcessCSRoutine()
        {
            this._partitionPath       = this._cmdletParameters["Partition"] as string;
            this._identityADPrincipal = this._cmdletParameters["Identity"] as ADPrincipal;
            base.SetPipelinedSessionInfo(this._identityADPrincipal.SessionInfo);
            CmdletSessionInfo cmdletSessionInfo = base.GetCmdletSessionInfo();
            ADPrincipalFactory <ADPrincipal> aDPrincipalFactory = new ADPrincipalFactory <ADPrincipal>();

            aDPrincipalFactory.SetCmdletSessionInfo(cmdletSessionInfo);
            this.ValidateParameters();
            ADObject directoryObjectFromIdentity = aDPrincipalFactory.GetDirectoryObjectFromIdentity(this._identityADPrincipal, cmdletSessionInfo.DefaultPartitionPath);

            using (ADAccountManagement aDAccountManagement = new ADAccountManagement(cmdletSessionInfo.ADSessionInfo))
            {
                if (!string.IsNullOrEmpty(this._resourceContextServer) && string.IsNullOrEmpty(this._resourceContextPartition))
                {
                    ADSessionInfo aDSessionInfo = cmdletSessionInfo.ADSessionInfo.Copy();
                    aDSessionInfo.Server = this._resourceContextServer;
                    using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(aDSessionInfo))
                    {
                        ADRootDSE rootDSE = aDObjectSearcher.GetRootDSE();
                        if (rootDSE.DefaultNamingContext != null)
                        {
                            this._resourceContextPartition = rootDSE.DefaultNamingContext;
                        }
                        else
                        {
                            object[] objArray = new object[1];
                            objArray[0] = "ResourceContextPartition";
                            base.ThrowTerminatingError(new ErrorRecord(new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ParameterRequired, objArray)), "1", ErrorCategory.InvalidArgument, null));
                        }
                    }
                }
                ADGroup[] principalGroupMembership = aDAccountManagement.GetPrincipalGroupMembership(cmdletSessionInfo.DefaultPartitionPath, directoryObjectFromIdentity.DistinguishedName, this._resourceContextServer, this._resourceContextPartition);
                ADGroup[] aDGroupArray             = principalGroupMembership;
                for (int i = 0; i < (int)aDGroupArray.Length; i++)
                {
                    ADGroup aDGroup = aDGroupArray[i];
                    base.WriteObject(aDGroup);
                }
            }
            return(true);
        }
Ejemplo n.º 4
0
        public static string ConvertPath(ADSessionInfo sessionInfo, string path, ADPathFormat fromFormat, ADPathFormat toFormat)
        {
            string str;

            if (fromFormat != toFormat)
            {
                if (fromFormat == ADPathFormat.Canonical && !string.IsNullOrEmpty(path) && CanonicalPath.IndexOfFirstDelimiter(path) == -1)
                {
                    path = string.Concat(path, "/");
                }
                using (ADAccountManagement aDAccountManagement = new ADAccountManagement(sessionInfo))
                {
                    str = aDAccountManagement.TranslateName(path, fromFormat, toFormat);
                }
                return(str);
            }
            else
            {
                return(path);
            }
        }
Ejemplo n.º 5
0
        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);
        }