Beispiel #1
0
        static void RetrieveAdminRoles()
        {
            Console.WriteLine("Start to sync AAD Roles ...");
            List<IDirectoryRole> foundRoles = null;
            try
            {
                foundRoles = activeDirectoryClient.DirectoryRoles.ExecuteAsync().Result.CurrentPage.ToList();
            }
            catch (Exception e)
            {
                Console.WriteLine("\nError getting Roles {0} {1}", e.Message,
                    e.InnerException != null ? e.InnerException.Message : "");
            }

            if (foundRoles != null && foundRoles.Count > 0)
            {
                foreach (IDirectoryRole role in foundRoles)
                {
                    //Console.WriteLine("\n Found Role: {0} {1} {2} ", role.DisplayName, role.Description, role.ObjectId);

                    var newAdminRole = new AdminRoleEntity(role.ObjectId, role.DisplayName);
                    newAdminRole.Description = role.Description;
                    newAdminRole.IsSystem = (bool)role.IsSystem;
                    newAdminRole.RoleDisabled = (bool)role.RoleDisabled;
                    //newAdminRole.MembersCount = role.Members.CurrentPage.Count;
                    adminRoleTableOper.InsertEntity(newAdminRole);
                }
            }

        }
Beispiel #2
0
 public bool InsertEntity(AdminRoleEntity adminRole)
 {
     var operation = TableOperation.InsertOrReplace(adminRole);
     _table.Execute(operation);
     return true;
 }