Esempio n. 1
0
        public ActionResult PlayWithSecurityGroups(PlayWithUsersViewModel model)
        {
            AntiForgery.Validate();

            var groups         = UsersGroupsHelper.ListGroups(100);
            var securityGroups = UsersGroupsHelper.ListSecurityGroups(100);
            var group          = UsersGroupsHelper.GetGroup(groups[0].Id);
            var owners         = UsersGroupsHelper.ListGroupOwners(group.Id);
            var members        = UsersGroupsHelper.ListGroupMembers(group.Id);

            var someone = UsersGroupsHelper.GetUser(model.UserPrincipalName);

            UsersGroupsHelper.AddMemberToGroup(someone, group.Id);
            members = UsersGroupsHelper.ListGroupMembers(group.Id);
            UsersGroupsHelper.RemoveMemberFromGroup(someone, group.Id);

            return(View("Index"));
        }
Esempio n. 2
0
        public ActionResult PlayWithUsers(PlayWithUsersViewModel model)
        {
            AntiForgery.Validate();

            var users                     = UsersGroupsHelper.ListUsers(600);
            var externalUsers             = UsersGroupsHelper.ListExternalUsers(600);
            var usersWithCustomAttributes = UsersGroupsHelper.ListUsers(
                new String[] { "id", "userPrincipalName", "mail",
                               "department", "country", "preferredLanguage",
                               "onPremisesImmutableId", "onPremisesSecurityIdentifier",
                               "onPremisesSyncEnabled", "userType" },
                600);

            try
            {
                var usersWorkingInIT = UsersGroupsHelper.ListUsersByDepartment("IT", 100);
                var oneUser          = UsersGroupsHelper.GetUser(model.UserPrincipalName);

                oneUser.City = "Brescia";
                UsersGroupsHelper.UpdateUser(oneUser);
            }
            catch (Exception)
            {
                // Something wrong while getting the thumbnail,
                // We will have to handle it properly ...
            }

            try
            {
                var newUser = UsersGroupsHelper.AddUser(
                    new Models.User
                {
                    AccountEnabled  = true,
                    DisplayName     = "API Created",
                    PasswordProfile = new Models.PasswordProfile
                    {
                        ForceChangePasswordNextSignIn = true,
                        Password = "******",
                    },
                    UserPrincipalName = $"api-created@{model.UserPrincipalName.Substring(model.UserPrincipalName.IndexOf("@") + 1)}",
                }
                    );
            }
            catch (Exception)
            {
                // Something wrong while getting the thumbnail,
                // We will have to handle it properly ...
            }

            try
            {
                var oneUserManager = UsersGroupsHelper.GetUserManager(model.UserPrincipalName);
                var oneUserManagerDirectReports = UsersGroupsHelper.GetUserDirectReports(oneUserManager.UserPrincipalName);
            }
            catch (Exception)
            {
                // Something wrong while getting the thumbnail,
                // We will have to handle it properly ...
            }

            return(View("Index"));
        }