コード例 #1
0
 public void CreateTrustRelationship(Domain targetDomain, TrustDirection direction)
 {
     base.CheckIfDisposed();
     if (targetDomain == null)
     {
         throw new ArgumentNullException("targetDomain");
     }
     if ((direction < TrustDirection.Inbound) || (direction > TrustDirection.Bidirectional))
     {
         throw new InvalidEnumArgumentException("direction", (int) direction, typeof(TrustDirection));
     }
     string password = TrustHelper.CreateTrustPassword();
     TrustHelper.CreateTrust(base.context, base.Name, targetDomain.GetDirectoryContext(), targetDomain.Name, false, direction, password);
     int num = 0;
     if ((direction & TrustDirection.Inbound) != ((TrustDirection) 0))
     {
         num |= 2;
     }
     if ((direction & TrustDirection.Outbound) != ((TrustDirection) 0))
     {
         num |= 1;
     }
     TrustHelper.CreateTrust(targetDomain.GetDirectoryContext(), targetDomain.Name, base.context, base.Name, false, (TrustDirection) num, password);
 }
コード例 #2
0
ファイル: Domain.cs プロジェクト: nickchal/pash
		public void VerifyTrustRelationship(Domain targetDomain, TrustDirection direction)
		{
			base.CheckIfDisposed();
			if (targetDomain != null)
			{
				if (direction < TrustDirection.Inbound || direction > TrustDirection.Bidirectional)
				{
					throw new InvalidEnumArgumentException("direction", (int)direction, typeof(TrustDirection));
				}
				else
				{
					if ((direction & TrustDirection.Outbound) != 0)
					{
						try
						{
							TrustHelper.VerifyTrust(this.context, base.Name, targetDomain.Name, false, TrustDirection.Outbound, false, null);
						}
						catch (ActiveDirectoryObjectNotFoundException activeDirectoryObjectNotFoundException)
						{
							object[] name = new object[3];
							name[0] = base.Name;
							name[1] = targetDomain.Name;
							name[2] = direction;
							throw new ActiveDirectoryObjectNotFoundException(Res.GetString("WrongTrustDirection", name), typeof(TrustRelationshipInformation), null);
						}
					}
					if ((direction & TrustDirection.Inbound) != 0)
					{
						try
						{
							TrustHelper.VerifyTrust(targetDomain.GetDirectoryContext(), targetDomain.Name, base.Name, false, TrustDirection.Outbound, false, null);
						}
						catch (ActiveDirectoryObjectNotFoundException activeDirectoryObjectNotFoundException1)
						{
							object[] objArray = new object[3];
							objArray[0] = base.Name;
							objArray[1] = targetDomain.Name;
							objArray[2] = direction;
							throw new ActiveDirectoryObjectNotFoundException(Res.GetString("WrongTrustDirection", objArray), typeof(TrustRelationshipInformation), null);
						}
					}
					return;
				}
			}
			else
			{
				throw new ArgumentNullException("targetDomain");
			}
		}
コード例 #3
0
ファイル: Domain.cs プロジェクト: nickchal/pash
		public void UpdateTrustRelationship(Domain targetDomain, TrustDirection newTrustDirection)
		{
			base.CheckIfDisposed();
			if (targetDomain != null)
			{
				if (newTrustDirection < TrustDirection.Inbound || newTrustDirection > TrustDirection.Bidirectional)
				{
					throw new InvalidEnumArgumentException("newTrustDirection", (int)newTrustDirection, typeof(TrustDirection));
				}
				else
				{
					string str = TrustHelper.CreateTrustPassword();
					TrustHelper.UpdateTrustDirection(this.context, base.Name, targetDomain.Name, str, false, newTrustDirection);
					TrustDirection trustDirection = 0;
					if ((newTrustDirection & TrustDirection.Inbound) != 0)
					{
						trustDirection = trustDirection | TrustDirection.Outbound;
					}
					if ((newTrustDirection & TrustDirection.Outbound) != 0)
					{
						trustDirection = trustDirection | TrustDirection.Inbound;
					}
					TrustHelper.UpdateTrustDirection(targetDomain.GetDirectoryContext(), targetDomain.Name, base.Name, str, false, trustDirection);
					return;
				}
			}
			else
			{
				throw new ArgumentNullException("targetDomain");
			}
		}
コード例 #4
0
ファイル: Domain.cs プロジェクト: nickchal/pash
		public void RepairTrustRelationship(Domain targetDomain)
		{
			TrustDirection trustDirection = TrustDirection.Bidirectional;
			base.CheckIfDisposed();
			if (targetDomain != null)
			{
				try
				{
					trustDirection = this.GetTrustRelationship(targetDomain.Name).TrustDirection;
					if ((trustDirection & TrustDirection.Outbound) != 0)
					{
						TrustHelper.VerifyTrust(this.context, base.Name, targetDomain.Name, false, TrustDirection.Outbound, true, null);
					}
					if ((trustDirection & TrustDirection.Inbound) != 0)
					{
						TrustHelper.VerifyTrust(targetDomain.GetDirectoryContext(), targetDomain.Name, base.Name, false, TrustDirection.Outbound, true, null);
					}
				}
				catch (ActiveDirectoryOperationException activeDirectoryOperationException)
				{
					this.RepairTrustHelper(targetDomain, trustDirection);
				}
				catch (UnauthorizedAccessException unauthorizedAccessException)
				{
					this.RepairTrustHelper(targetDomain, trustDirection);
				}
				catch (ActiveDirectoryObjectNotFoundException activeDirectoryObjectNotFoundException)
				{
					object[] name = new object[3];
					name[0] = base.Name;
					name[1] = targetDomain.Name;
					name[2] = trustDirection;
					throw new ActiveDirectoryObjectNotFoundException(Res.GetString("WrongTrustDirection", name), typeof(TrustRelationshipInformation), null);
				}
				return;
			}
			else
			{
				throw new ArgumentNullException("targetDomain");
			}
		}
コード例 #5
0
ファイル: Domain.cs プロジェクト: nickchal/pash
		private void RepairTrustHelper(Domain targetDomain, TrustDirection direction)
		{
			string str = TrustHelper.CreateTrustPassword();
			string str1 = TrustHelper.UpdateTrust(targetDomain.GetDirectoryContext(), targetDomain.Name, base.Name, str, false);
			string str2 = TrustHelper.UpdateTrust(this.context, base.Name, targetDomain.Name, str, false);
			if ((direction & TrustDirection.Outbound) != 0)
			{
				try
				{
					TrustHelper.VerifyTrust(this.context, base.Name, targetDomain.Name, false, TrustDirection.Outbound, true, str1);
				}
				catch (ActiveDirectoryObjectNotFoundException activeDirectoryObjectNotFoundException)
				{
					object[] name = new object[3];
					name[0] = base.Name;
					name[1] = targetDomain.Name;
					name[2] = direction;
					throw new ActiveDirectoryObjectNotFoundException(Res.GetString("WrongTrustDirection", name), typeof(TrustRelationshipInformation), null);
				}
			}
			if ((direction & TrustDirection.Inbound) != 0)
			{
				try
				{
					TrustHelper.VerifyTrust(targetDomain.GetDirectoryContext(), targetDomain.Name, base.Name, false, TrustDirection.Outbound, true, str2);
				}
				catch (ActiveDirectoryObjectNotFoundException activeDirectoryObjectNotFoundException1)
				{
					object[] objArray = new object[3];
					objArray[0] = base.Name;
					objArray[1] = targetDomain.Name;
					objArray[2] = direction;
					throw new ActiveDirectoryObjectNotFoundException(Res.GetString("WrongTrustDirection", objArray), typeof(TrustRelationshipInformation), null);
				}
			}
		}
コード例 #6
0
ファイル: Domain.cs プロジェクト: chcosta/corefx
        public void RepairTrustRelationship(Domain targetDomain)
        {
            TrustDirection direction = TrustDirection.Bidirectional;

            CheckIfDisposed();

            if (targetDomain == null)
                throw new ArgumentNullException("targetDomain");

            // first try to reset the secure channel
            try
            {
                direction = GetTrustRelationship(targetDomain.Name).TrustDirection;

                // verify outbound trust first
                if ((direction & TrustDirection.Outbound) != 0)
                {
                    TrustHelper.VerifyTrust(context, Name, targetDomain.Name, false /*not forest*/, TrustDirection.Outbound, true /*reset secure channel*/, null /* no need to go to specific server*/);
                }

                // verify inbound trust
                if ((direction & TrustDirection.Inbound) != 0)
                {
                    TrustHelper.VerifyTrust(targetDomain.GetDirectoryContext(), targetDomain.Name, Name, false /*not forest*/, TrustDirection.Outbound, true/*reset secure channel*/, null /* no need to go to specific server*/);
                }
            }
            catch (ActiveDirectoryOperationException)
            {
                // secure channel setup fails
                RepairTrustHelper(targetDomain, direction);
            }
            catch (UnauthorizedAccessException)
            {
                // trust password does not match
                RepairTrustHelper(targetDomain, direction);
            }
            catch (ActiveDirectoryObjectNotFoundException)
            {
                throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.WrongTrustDirection, Name, targetDomain.Name, direction), typeof(TrustRelationshipInformation), null);
            }
        }
コード例 #7
0
ファイル: Domain.cs プロジェクト: chcosta/corefx
        public void UpdateTrustRelationship(Domain targetDomain, TrustDirection newTrustDirection)
        {
            CheckIfDisposed();

            if (targetDomain == null)
                throw new ArgumentNullException("targetDomain");

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

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

            TrustHelper.UpdateTrustDirection(context, Name, targetDomain.Name, password, false /* not a 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(targetDomain.GetDirectoryContext(), targetDomain.Name, Name, password, false /* not a forest */, reverseDirection);
        }
コード例 #8
0
 private void RepairTrustHelper(Domain targetDomain, TrustDirection direction)
 {
     string password = TrustHelper.CreateTrustPassword();
     string preferredTargetServer = TrustHelper.UpdateTrust(targetDomain.GetDirectoryContext(), targetDomain.Name, base.Name, password, false);
     string str3 = TrustHelper.UpdateTrust(base.context, base.Name, targetDomain.Name, password, false);
     if ((direction & TrustDirection.Outbound) != ((TrustDirection) 0))
     {
         try
         {
             TrustHelper.VerifyTrust(base.context, base.Name, targetDomain.Name, false, TrustDirection.Outbound, true, preferredTargetServer);
         }
         catch (ActiveDirectoryObjectNotFoundException)
         {
             throw new ActiveDirectoryObjectNotFoundException(Res.GetString("WrongTrustDirection", new object[] { base.Name, targetDomain.Name, direction }), typeof(TrustRelationshipInformation), null);
         }
     }
     if ((direction & TrustDirection.Inbound) != ((TrustDirection) 0))
     {
         try
         {
             TrustHelper.VerifyTrust(targetDomain.GetDirectoryContext(), targetDomain.Name, base.Name, false, TrustDirection.Outbound, true, str3);
         }
         catch (ActiveDirectoryObjectNotFoundException)
         {
             throw new ActiveDirectoryObjectNotFoundException(Res.GetString("WrongTrustDirection", new object[] { base.Name, targetDomain.Name, direction }), typeof(TrustRelationshipInformation), null);
         }
     }
 }
コード例 #9
0
ファイル: Domain.cs プロジェクト: chcosta/corefx
        public void VerifyTrustRelationship(Domain targetDomain, TrustDirection direction)
        {
            CheckIfDisposed();

            if (targetDomain == null)
                throw new ArgumentNullException("targetDomain");

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

            // verify outbound trust first
            if ((direction & TrustDirection.Outbound) != 0)
            {
                try
                {
                    TrustHelper.VerifyTrust(context, Name, targetDomain.Name, false/*not forest*/, TrustDirection.Outbound, false/*just TC verification*/, null /* no need to go to specific server*/);
                }
                catch (ActiveDirectoryObjectNotFoundException)
                {
                    throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.WrongTrustDirection, Name, targetDomain.Name, direction), typeof(TrustRelationshipInformation), null);
                }
            }

            // verify inbound trust
            if ((direction & TrustDirection.Inbound) != 0)
            {
                try
                {
                    TrustHelper.VerifyTrust(targetDomain.GetDirectoryContext(), targetDomain.Name, Name, false/*not forest*/, TrustDirection.Outbound, false/*just TC verification*/, null /* no need to go to specific server*/);
                }
                catch (ActiveDirectoryObjectNotFoundException)
                {
                    throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.WrongTrustDirection, Name, targetDomain.Name, direction), typeof(TrustRelationshipInformation), null);
                }
            }
        }
コード例 #10
0
ファイル: Domain.cs プロジェクト: chcosta/corefx
        public void DeleteTrustRelationship(Domain targetDomain)
        {
            CheckIfDisposed();

            if (targetDomain == null)
                throw new ArgumentNullException("targetDomain");

            // first delete the trust on the remote side
            TrustHelper.DeleteTrust(targetDomain.GetDirectoryContext(), targetDomain.Name, Name, false);

            // then delete the local side trust
            TrustHelper.DeleteTrust(context, Name, targetDomain.Name, false);
        }
コード例 #11
0
ファイル: Domain.cs プロジェクト: chcosta/corefx
        private void RepairTrustHelper(Domain targetDomain, TrustDirection direction)
        {
            // now we try changing trust password on both sides
            string password = TrustHelper.CreateTrustPassword();

            // first reset trust password on remote side
            string targetServerName = TrustHelper.UpdateTrust(targetDomain.GetDirectoryContext(), targetDomain.Name, Name, password, false);

            // then reset trust password on local side
            string sourceServerName = TrustHelper.UpdateTrust(context, Name, targetDomain.Name, password, false);

            // last we reset the secure channel again to make sure info is replicated and trust is indeed ready now

            // verify outbound trust first
            if ((direction & TrustDirection.Outbound) != 0)
            {
                try
                {
                    TrustHelper.VerifyTrust(context, Name, targetDomain.Name, false /*not forest*/, TrustDirection.Outbound, true /*reset secure channel*/, targetServerName /* need to specify which target server */);
                }
                catch (ActiveDirectoryObjectNotFoundException)
                {
                    throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.WrongTrustDirection, Name, targetDomain.Name, direction), typeof(TrustRelationshipInformation), null);
                }
            }

            // verify inbound trust
            if ((direction & TrustDirection.Inbound) != 0)
            {
                try
                {
                    TrustHelper.VerifyTrust(targetDomain.GetDirectoryContext(), targetDomain.Name, Name, false /*not forest*/, TrustDirection.Outbound, true/*reset secure channel*/, sourceServerName /* need to specify which target server */);
                }
                catch (ActiveDirectoryObjectNotFoundException)
                {
                    throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.WrongTrustDirection, Name, targetDomain.Name, direction), typeof(TrustRelationshipInformation), null);
                }
            }
        }
コード例 #12
0
 public void VerifyTrustRelationship(Domain targetDomain, TrustDirection direction)
 {
     base.CheckIfDisposed();
     if (targetDomain == null)
     {
         throw new ArgumentNullException("targetDomain");
     }
     if ((direction < TrustDirection.Inbound) || (direction > TrustDirection.Bidirectional))
     {
         throw new InvalidEnumArgumentException("direction", (int) direction, typeof(TrustDirection));
     }
     if ((direction & TrustDirection.Outbound) != ((TrustDirection) 0))
     {
         try
         {
             TrustHelper.VerifyTrust(base.context, base.Name, targetDomain.Name, false, TrustDirection.Outbound, false, null);
         }
         catch (ActiveDirectoryObjectNotFoundException)
         {
             throw new ActiveDirectoryObjectNotFoundException(Res.GetString("WrongTrustDirection", new object[] { base.Name, targetDomain.Name, direction }), typeof(TrustRelationshipInformation), null);
         }
     }
     if ((direction & TrustDirection.Inbound) != ((TrustDirection) 0))
     {
         try
         {
             TrustHelper.VerifyTrust(targetDomain.GetDirectoryContext(), targetDomain.Name, base.Name, false, TrustDirection.Outbound, false, null);
         }
         catch (ActiveDirectoryObjectNotFoundException)
         {
             throw new ActiveDirectoryObjectNotFoundException(Res.GetString("WrongTrustDirection", new object[] { base.Name, targetDomain.Name, direction }), typeof(TrustRelationshipInformation), null);
         }
     }
 }
コード例 #13
0
 public void UpdateTrustRelationship(Domain targetDomain, TrustDirection newTrustDirection)
 {
     base.CheckIfDisposed();
     if (targetDomain == null)
     {
         throw new ArgumentNullException("targetDomain");
     }
     if ((newTrustDirection < TrustDirection.Inbound) || (newTrustDirection > TrustDirection.Bidirectional))
     {
         throw new InvalidEnumArgumentException("newTrustDirection", (int) newTrustDirection, typeof(TrustDirection));
     }
     string password = TrustHelper.CreateTrustPassword();
     TrustHelper.UpdateTrustDirection(base.context, base.Name, targetDomain.Name, password, false, 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(targetDomain.GetDirectoryContext(), targetDomain.Name, base.Name, password, false, direction);
 }
コード例 #14
0
 public void RepairTrustRelationship(Domain targetDomain)
 {
     TrustDirection bidirectional = TrustDirection.Bidirectional;
     base.CheckIfDisposed();
     if (targetDomain == null)
     {
         throw new ArgumentNullException("targetDomain");
     }
     try
     {
         bidirectional = this.GetTrustRelationship(targetDomain.Name).TrustDirection;
         if ((bidirectional & TrustDirection.Outbound) != ((TrustDirection) 0))
         {
             TrustHelper.VerifyTrust(base.context, base.Name, targetDomain.Name, false, TrustDirection.Outbound, true, null);
         }
         if ((bidirectional & TrustDirection.Inbound) != ((TrustDirection) 0))
         {
             TrustHelper.VerifyTrust(targetDomain.GetDirectoryContext(), targetDomain.Name, base.Name, false, TrustDirection.Outbound, true, null);
         }
     }
     catch (ActiveDirectoryOperationException)
     {
         this.RepairTrustHelper(targetDomain, bidirectional);
     }
     catch (UnauthorizedAccessException)
     {
         this.RepairTrustHelper(targetDomain, bidirectional);
     }
     catch (ActiveDirectoryObjectNotFoundException)
     {
         throw new ActiveDirectoryObjectNotFoundException(Res.GetString("WrongTrustDirection", new object[] { base.Name, targetDomain.Name, bidirectional }), typeof(TrustRelationshipInformation), null);
     }
 }
コード例 #15
0
ファイル: Domain.cs プロジェクト: nickchal/pash
		public void CreateTrustRelationship(Domain targetDomain, TrustDirection direction)
		{
			base.CheckIfDisposed();
			if (targetDomain != null)
			{
				if (direction < TrustDirection.Inbound || direction > TrustDirection.Bidirectional)
				{
					throw new InvalidEnumArgumentException("direction", (int)direction, typeof(TrustDirection));
				}
				else
				{
					string str = TrustHelper.CreateTrustPassword();
					TrustHelper.CreateTrust(this.context, base.Name, targetDomain.GetDirectoryContext(), targetDomain.Name, false, direction, str);
					int num = 0;
					if ((direction & TrustDirection.Inbound) != 0)
					{
						num = num | 2;
					}
					if ((direction & TrustDirection.Outbound) != 0)
					{
						num = num | 1;
					}
					TrustHelper.CreateTrust(targetDomain.GetDirectoryContext(), targetDomain.Name, this.context, base.Name, false, (TrustDirection)num, str);
					return;
				}
			}
			else
			{
				throw new ArgumentNullException("targetDomain");
			}
		}
コード例 #16
0
ファイル: Domain.cs プロジェクト: nickchal/pash
		public void DeleteTrustRelationship(Domain targetDomain)
		{
			base.CheckIfDisposed();
			if (targetDomain != null)
			{
				TrustHelper.DeleteTrust(targetDomain.GetDirectoryContext(), targetDomain.Name, base.Name, false);
				TrustHelper.DeleteTrust(this.context, base.Name, targetDomain.Name, false);
				return;
			}
			else
			{
				throw new ArgumentNullException("targetDomain");
			}
		}
コード例 #17
0
ファイル: Domain.cs プロジェクト: chcosta/corefx
        public void CreateTrustRelationship(Domain targetDomain, TrustDirection direction)
        {
            CheckIfDisposed();

            if (targetDomain == null)
                throw new ArgumentNullException("targetDomain");

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

            string password = TrustHelper.CreateTrustPassword();

            // first create trust on local side                  
            TrustHelper.CreateTrust(context, Name, targetDomain.GetDirectoryContext(), targetDomain.Name, false, 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(targetDomain.GetDirectoryContext(), targetDomain.Name, context, Name, false, (TrustDirection)reverseDirection, password);
        }