Esempio n. 1
0
        public void UpdateTrustRelationship(Forest targetForest, TrustDirection newTrustDirection)
        {
            CheckIfDisposed();

            if (targetForest == null)
            {
                throw new ArgumentNullException(nameof(targetForest));
            }

            if (newTrustDirection < TrustDirection.Inbound || newTrustDirection > TrustDirection.Bidirectional)
            {
                throw new InvalidEnumArgumentException(nameof(newTrustDirection), (int)newTrustDirection, typeof(TrustDirection));
            }

            // no we generate trust password
            string password = TrustHelper.CreateTrustPassword();

            TrustHelper.UpdateTrustDirection(_context, Name, targetForest.Name, password, true /*is forest*/, newTrustDirection);

            // then create trust on remote side
            TrustDirection reverseDirection = 0;

            if ((newTrustDirection & TrustDirection.Inbound) != 0)
            {
                reverseDirection |= TrustDirection.Outbound;
            }
            if ((newTrustDirection & TrustDirection.Outbound) != 0)
            {
                reverseDirection |= TrustDirection.Inbound;
            }

            TrustHelper.UpdateTrustDirection(targetForest.GetDirectoryContext(), targetForest.Name, Name, password, true /*is forest*/, reverseDirection);
        }
Esempio n. 2
0
        public void CreateTrustRelationship(Forest targetForest, TrustDirection direction)
        {
            CheckIfDisposed();

            if (targetForest == null)
            {
                throw new ArgumentNullException(nameof(targetForest));
            }

            if (direction < TrustDirection.Inbound || direction > TrustDirection.Bidirectional)
            {
                throw new InvalidEnumArgumentException(nameof(direction), (int)direction, typeof(TrustDirection));
            }

            string password = TrustHelper.CreateTrustPassword();

            // first create trust on local side
            TrustHelper.CreateTrust(_context, Name, targetForest.GetDirectoryContext(), targetForest.Name, true, direction, password);

            // then create trust on remote side
            int reverseDirection = 0;

            if ((direction & TrustDirection.Inbound) != 0)
            {
                reverseDirection |= (int)TrustDirection.Outbound;
            }
            if ((direction & TrustDirection.Outbound) != 0)
            {
                reverseDirection |= (int)TrustDirection.Inbound;
            }

            TrustHelper.CreateTrust(targetForest.GetDirectoryContext(), targetForest.Name, _context, Name, true, (TrustDirection)reverseDirection, password);
        }
        public void CreateTrustRelationship(Forest targetForest, TrustDirection direction)
        {
            this.CheckIfDisposed();
            if (targetForest == null)
            {
                throw new ArgumentNullException("targetForest");
            }
            if ((direction < TrustDirection.Inbound) || (direction > TrustDirection.Bidirectional))
            {
                throw new InvalidEnumArgumentException("direction", (int)direction, typeof(TrustDirection));
            }
            string password = TrustHelper.CreateTrustPassword();

            TrustHelper.CreateTrust(this.context, this.Name, targetForest.GetDirectoryContext(), targetForest.Name, true, direction, password);
            int num = 0;

            if ((direction & TrustDirection.Inbound) != ((TrustDirection)0))
            {
                num |= 2;
            }
            if ((direction & TrustDirection.Outbound) != ((TrustDirection)0))
            {
                num |= 1;
            }
            TrustHelper.CreateTrust(targetForest.GetDirectoryContext(), targetForest.Name, this.context, this.Name, true, (TrustDirection)num, password);
        }
        public void UpdateTrustRelationship(Forest targetForest, TrustDirection newTrustDirection)
        {
            this.CheckIfDisposed();
            if (targetForest == null)
            {
                throw new ArgumentNullException("targetForest");
            }
            if ((newTrustDirection < TrustDirection.Inbound) || (newTrustDirection > TrustDirection.Bidirectional))
            {
                throw new InvalidEnumArgumentException("newTrustDirection", (int)newTrustDirection, typeof(TrustDirection));
            }
            string password = TrustHelper.CreateTrustPassword();

            TrustHelper.UpdateTrustDirection(this.context, this.Name, targetForest.Name, password, true, newTrustDirection);
            TrustDirection direction = (TrustDirection)0;

            if ((newTrustDirection & TrustDirection.Inbound) != ((TrustDirection)0))
            {
                direction |= TrustDirection.Outbound;
            }
            if ((newTrustDirection & TrustDirection.Outbound) != ((TrustDirection)0))
            {
                direction |= TrustDirection.Inbound;
            }
            TrustHelper.UpdateTrustDirection(targetForest.GetDirectoryContext(), targetForest.Name, this.Name, password, true, direction);
        }
        private void RepairTrustHelper(Forest targetForest, TrustDirection direction)
        {
            string password = TrustHelper.CreateTrustPassword();
            string preferredTargetServer = TrustHelper.UpdateTrust(targetForest.GetDirectoryContext(), targetForest.Name, this.Name, password, true);
            string str3 = TrustHelper.UpdateTrust(this.context, this.Name, targetForest.Name, password, true);

            if ((direction & TrustDirection.Outbound) != ((TrustDirection)0))
            {
                try
                {
                    TrustHelper.VerifyTrust(this.context, this.Name, targetForest.Name, true, TrustDirection.Outbound, true, preferredTargetServer);
                }
                catch (ActiveDirectoryObjectNotFoundException)
                {
                    throw new ActiveDirectoryObjectNotFoundException(Res.GetString("WrongTrustDirection", new object[] { this.Name, targetForest.Name, direction }), typeof(ForestTrustRelationshipInformation), null);
                }
            }
            if ((direction & TrustDirection.Inbound) != ((TrustDirection)0))
            {
                try
                {
                    TrustHelper.VerifyTrust(targetForest.GetDirectoryContext(), targetForest.Name, this.Name, true, TrustDirection.Outbound, true, str3);
                }
                catch (ActiveDirectoryObjectNotFoundException)
                {
                    throw new ActiveDirectoryObjectNotFoundException(Res.GetString("WrongTrustDirection", new object[] { this.Name, targetForest.Name, direction }), typeof(ForestTrustRelationshipInformation), null);
                }
            }
        }