public void TestManagerIsMember() { Group e = null; User user = null; try { e = UnitTestControl.CreateGroup(); Thread.Sleep(1000); user = UserTests.CreateUser(); UnitTestControl.TestParameters.GroupsService.MemberFactory.AddMember(e.Email, new Member() { Email = user.PrimaryEmail, Role = "MANAGER" }); Thread.Sleep(5000); GroupMembership members = UnitTestControl.TestParameters.GroupsService.MemberFactory.GetMembership(e.Email); ApiInterfaceGroupMembership i = new ApiInterfaceGroupMembership(UnitTestControl.TestParameters); IList <AttributeChange> changes = i.GetChanges(e.Email, ObjectModificationType.Add, UnitTestControl.MmsSchema.Types["group"], members); AttributeChange manager = changes.First(t => t.Name == "manager"); AttributeChange member = changes.First(t => t.Name == "member"); Assert.AreEqual(manager.ValueChanges.First().Value, user.PrimaryEmail); Assert.AreEqual(member.ValueChanges.First().Value, user.PrimaryEmail); } finally { UnitTestControl.Cleanup(e, user); } }
public User Patch(User item, string userKey) { using (PoolItem <DirectoryService> connection = this.directoryServicePool.Take(NullValueHandling.Ignore)) { UserPatchRequest request = new UserPatchRequest(connection.Item, item, userKey); return(request.ExecuteWithRetryOnBackoff()); } }
public User Add(User item) { using (PoolItem <DirectoryService> connection = this.directoryServicePool.Take(NullValueHandling.Ignore)) { InsertRequest request = new InsertRequest(connection.Item, item); return(request.ExecuteWithRetryOnBackoff()); } }
public void DowngradeManagersToMembers() { Group e = null; User member1 = null; User member2 = null; User member3 = null; User member4 = null; try { e = UnitTestControl.CreateGroup(); member1 = UserTests.CreateUser(); member2 = UserTests.CreateUser(); member3 = UserTests.CreateUser(); member4 = UserTests.CreateUser(); UnitTestControl.TestParameters.GroupsService.MemberFactory.AddMember(e.Email, member1.PrimaryEmail, "MANAGER"); UnitTestControl.TestParameters.GroupsService.MemberFactory.AddMember(e.Email, member2.PrimaryEmail, "MANAGER"); UnitTestControl.TestParameters.GroupsService.MemberFactory.AddMember(e.Email, member3.PrimaryEmail, "MEMBER"); UnitTestControl.TestParameters.GroupsService.MemberFactory.AddMember(e.Email, member4.PrimaryEmail, "MEMBER"); Thread.Sleep(1000); CSEntryChange cs = CSEntryChange.Create(); cs.ObjectModificationType = ObjectModificationType.Update; cs.DN = e.Email; cs.ObjectType = SchemaConstants.Group; cs.AnchorAttributes.Add(AnchorAttribute.Create("id", e.Email)); cs.AttributeChanges.Add(AttributeChange.CreateAttributeDelete("manager")); CSEntryChangeResult result = ExportProcessor.PutCSEntryChange(cs, UnitTestControl.Schema.GetSchema().Types[SchemaConstants.Group], UnitTestControl.TestParameters); if (result.ErrorCode != MAExportError.Success) { Assert.Fail(result.ErrorName); } Thread.Sleep(1000); GroupMembership membership = UnitTestControl.TestParameters.GroupsService.MemberFactory.GetMembership(cs.DN); Assert.AreEqual(0, membership.ExternalManagers.Count); Assert.AreEqual(0, membership.Managers.Count); Assert.AreEqual(0, membership.ExternalMembers.Count); CollectionAssert.AreEquivalent(new string[] { member1.PrimaryEmail, member2.PrimaryEmail, member3.PrimaryEmail, member4.PrimaryEmail }, membership.Members.ToArray()); } finally { UnitTestControl.Cleanup(e, member1, member2, member3, member4); } }
public User Update(User item, string userKey) { if (item.Creating) { return(this.Add(item)); } using (PoolItem <DirectoryService> connection = this.directoryServicePool.Take(NullValueHandling.Include)) { UserUpdateRequest request = new UserUpdateRequest(connection.Item, item, userKey); return(request.ExecuteWithRetryOnBackoff()); } }
public void SetPassword(string id, string newPassword) { using (PoolItem <DirectoryService> connection = this.directoryServicePool.Take(NullValueHandling.Ignore)) { User user = new User { Password = newPassword }; UserPatchRequest request = new UserPatchRequest(connection.Item, user, id); request.ExecuteWithRetryOnBackoff(); } }