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 CreateLocalSideOfTrustRelationship(string targetForestName, TrustDirection direction, string trustPassword) { this.CheckIfDisposed(); if (targetForestName == null) { throw new ArgumentNullException("targetForestName"); } if (targetForestName.Length == 0) { throw new ArgumentException(Res.GetString("EmptyStringParameter"), "targetForestName"); } if ((direction < TrustDirection.Inbound) || (direction > TrustDirection.Bidirectional)) { throw new InvalidEnumArgumentException("direction", (int)direction, typeof(TrustDirection)); } if (trustPassword == null) { throw new ArgumentNullException("trustPassword"); } if (trustPassword.Length == 0) { throw new ArgumentException(Res.GetString("EmptyStringParameter"), "trustPassword"); } Locator.GetDomainControllerInfo(null, targetForestName, null, 80L); DirectoryContext targetContext = Utils.GetNewDirectoryContext(targetForestName, DirectoryContextType.Forest, this.context); TrustHelper.CreateTrust(this.context, this.Name, targetContext, targetForestName, true, direction, trustPassword); }
public void CreateLocalSideOfTrustRelationship(string targetForestName, TrustDirection direction, string trustPassword) { CheckIfDisposed(); if (targetForestName == null) { throw new ArgumentNullException(nameof(targetForestName)); } if (targetForestName.Length == 0) { throw new ArgumentException(SR.EmptyStringParameter, nameof(targetForestName)); } if (direction < TrustDirection.Inbound || direction > TrustDirection.Bidirectional) { throw new InvalidEnumArgumentException(nameof(direction), (int)direction, typeof(TrustDirection)); } if (trustPassword == null) { throw new ArgumentNullException(nameof(trustPassword)); } if (trustPassword.Length == 0) { throw new ArgumentException(SR.EmptyStringParameter, nameof(trustPassword)); } // verify first that the target forest name is valid Locator.GetDomainControllerInfo(null, targetForestName, null, (long)(PrivateLocatorFlags.DirectoryServicesRequired | PrivateLocatorFlags.GCRequired)); DirectoryContext targetContext = Utils.GetNewDirectoryContext(targetForestName, DirectoryContextType.Forest, _context); TrustHelper.CreateTrust(_context, Name, targetContext, targetForestName, true, direction, trustPassword); }