public DataTypes.Group UpdateLocalGroup(DataTypes.Group group, string description)
        {
            if (description == null)
            {
                description = string.Empty;
            }

            // Create Authorization Invocation Context
            var authorizedInvocationContext =
                CreateAuthorizedInvocationContext();

            // Invoke SSO Admin DeleteLocalPrincipal operation
            var updatedGroup = authorizedInvocationContext.
                               InvokeOperation(() =>
                                               _ssoAdminBindingClient.UpdateLocalGroupDetailsAsync(
                                                   new ManagedObjectReference
            {
                type  = "SsoAdminPrincipalManagementService",
                Value = "principalManagementService"
            },
                                                   group.Name,
                                                   new SsoAdminGroupDetails
            {
                description = description
            })).Result;

            if (updatedGroup != null)
            {
                return(FindGroup(updatedGroup.name, updatedGroup.domain, authorizedInvocationContext));
            }
            else
            {
                return(null);
            }
        }
        public void RemoveLocalGroup(DataTypes.Group group)
        {
            // Create Authorization Invocation Context
            var authorizedInvocationContext =
                CreateAuthorizedInvocationContext();

            // Invoke SSO Admin DeleteLocalPrincipal operation
            authorizedInvocationContext.
            InvokeOperation(() =>
                            _ssoAdminBindingClient.DeleteLocalPrincipalAsync(
                                new ManagedObjectReference
            {
                type  = "SsoAdminPrincipalManagementService",
                Value = "principalManagementService"
            },
                                group.Name));
        }
        public bool RemovePersonUserFromGroup(PersonUser user, DataTypes.Group group)
        {
            // Create Authorization Invocation Context
            var authorizedInvocationContext =
                CreateAuthorizedInvocationContext();

            // Invoke SSO Admin RemoveFromLocalGroupAsync operation
            return(authorizedInvocationContext.
                   InvokeOperation(() =>
                                   _ssoAdminBindingClient.RemoveFromLocalGroupAsync(
                                       new ManagedObjectReference {
                type = "SsoAdminPrincipalManagementService",
                Value = "principalManagementService"
            },
                                       new SsoPrincipalId {
                name = user.Name,
                domain = user.Domain
            },
                                       group.Name)).Result);
        }
        public IEnumerable <PersonUser> GetPersonUsersInGroup(string searchString, DataTypes.Group group)
        {
            // Create Authorization Invocation Context
            var authorizedInvocationContext =
                CreateAuthorizedInvocationContext();

            // Invoke SSO Admin FindPersonUsersAsync operation
            var personUsers = authorizedInvocationContext.
                              InvokeOperation(() =>
                                              _ssoAdminBindingClient.FindPersonUsersInGroupAsync(
                                                  new ManagedObjectReference
            {
                type  = "SsoAdminPrincipalDiscoveryService",
                Value = "principalDiscoveryService"
            },
                                                  new SsoPrincipalId
            {
                name   = group.Name,
                domain = group.Domain
            },
                                                  searchString,
                                                  int.MaxValue)).Result.returnval;

            if (personUsers != null)
            {
                foreach (var personUser in personUsers)
                {
                    yield return(new PersonUser(this)
                    {
                        Name = personUser.id.name,
                        Domain = personUser.id.domain,
                        Description = personUser.details.description,
                        FirstName = personUser.details.firstName,
                        LastName = personUser.details.lastName,
                        EmailAddress = personUser.details.emailAddress,
                        Locked = personUser.locked,
                        Disabled = personUser.disabled
                    });
                }
            }
        }
        public bool AddGroupToGroup(DataTypes.Group groupToAdd, DataTypes.Group destinationGroup)
        {
            // Create Authorization Invocation Context
            var authorizedInvocationContext =
                CreateAuthorizedInvocationContext();

            // Invoke SSO Admin AddGroupToLocalGroupAsync operation
            return(authorizedInvocationContext.
                   InvokeOperation(() =>
                                   _ssoAdminBindingClient.AddGroupToLocalGroupAsync(
                                       new ManagedObjectReference
            {
                type = "SsoAdminPrincipalManagementService",
                Value = "principalManagementService"
            },
                                       new SsoPrincipalId
            {
                name = groupToAdd.Name,
                domain = groupToAdd.Domain
            },
                                       destinationGroup.Name)).Result);
        }
        public IEnumerable <DataTypes.Group> GetGroupsInGroup(string searchString, DataTypes.Group group)
        {
            // Create Authorization Invocation Context
            var authorizedInvocationContext =
                CreateAuthorizedInvocationContext();

            // Invoke SSO Admin FindGroupsInGroupResponse operation
            var groups = authorizedInvocationContext.
                         InvokeOperation(() =>
                                         _ssoAdminBindingClient.FindGroupsInGroupAsync(
                                             new ManagedObjectReference
            {
                type  = "SsoAdminPrincipalDiscoveryService",
                Value = "principalDiscoveryService"
            },
                                             new SsoPrincipalId
            {
                name   = group.Name,
                domain = group.Domain
            },
                                             searchString,
                                             int.MaxValue)).Result.returnval;

            if (groups != null)
            {
                foreach (var g in groups)
                {
                    yield return(new DataTypes.Group(this)
                    {
                        Name = g.id.name,
                        Domain = g.id.domain,
                        Description = g.details.description
                    });
                }
            }
        }