)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » Identity (Ia.Cl.Model)

Public general use code classes and xml files that we've compiled and used over the years:

ASP.NET Identity support class.

    1: using Microsoft.AspNetCore.Authentication;
    2: using Microsoft.AspNetCore.Http;
    3: using Microsoft.AspNetCore.Identity;
    4: using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
    5: using System;
    6: using System.Collections.Generic;
    7: using System.Linq;
    8:  
    9: namespace Ia.Cl.Model
   10: {
   11:     ////////////////////////////////////////////////////////////////////////////
   12:  
   13:     /// <summary publish="true">
   14:     /// ASP.NET Identity support class.
   15:     /// </summary>
   16:     /// <remarks> 
   17:     /// Copyright © 2014-2024 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   18:     ///
   19:     /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
   20:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   21:     ///
   22:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   23:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   24:     /// 
   25:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   26:     /// 
   27:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   28:     /// </remarks> 
   29:     public class Identity
   30:     {
   31:         private static Dictionary<Guid, string> guidToUserNameDictionary;
   32:         private static List<IdentityUser> identityUserList;
   33:         private static List<IdentityRole> identityRoleList;
   34:  
   35:         private static readonly object objectLock = new object();
   36:  
   37:         ////////////////////////////////////////////////////////////////////////////
   38:  
   39:         /// <summary>
   40:         ///
   41:         /// </summary>
   42:         public static IdentityUser CreateUser(string userName, string password, string confirmPassword, out IdentityResult identityResult)
   43:         {
   44:             return CreateUser(userName, password, confirmPassword, null, null, null, out identityResult);
   45:         }
   46:  
   47:         ////////////////////////////////////////////////////////////////////////////
   48:  
   49:         /// <summary>
   50:         ///
   51:         /// </summary>
   52:         public static IdentityUser CreateUser(string userName, string password, string confirmPassword, string email, out IdentityResult identityResult)
   53:         {
   54:             return CreateUser(userName, password, confirmPassword, email, null, null, out identityResult);
   55:         }
   56:  
   57:         ////////////////////////////////////////////////////////////////////////////
   58:  
   59:         /// <summary>
   60:         ///
   61:         /// </summary>
   62:         public static IdentityUser CreateUserWithNoEmailNoPassword(string userName, out IdentityResult identityResult)
   63:         {
   64:             return CreateUser(userName, null, null, null, null, null, out identityResult);
   65:         }
   66:  
   67:         ////////////////////////////////////////////////////////////////////////////
   68:  
   69:         /// <summary>
   70:         ///
   71:         /// </summary>
   72:         public static IdentityUser CreateUser(string userName, string password, string confirmPassword, string email, string question, string answer, out IdentityResult identityResult)
   73:         {
   74:             var userStore = new UserStore<IdentityUser>(); // default UserStore constructor uses the default connection string named: DefaultConnection
   75:             var userManager = new UserManager<IdentityUser>(userStore);
   76:  
   77:             var identityUser = new IdentityUser() { UserName = userName };
   78:  
   79:             identityUser.Email = email;
   80:  
   81:             identityResult = userManager.Create(identityUser, password);
   82:  
   83:             if (identityResult.Succeeded)
   84:             {
   85:                 var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
   86:                 var userIdentity = userManager.CreateIdentity(identityUser, DefaultAuthenticationTypes.ApplicationCookie);
   87:  
   88:                 authenticationManager.SignIn(new AuthenticationProperties() { }, userIdentity);
   89:             }
   90:             else
   91:             {
   92:             }
   93:  
   94:             identityUserList = null;
   95:  
   96:             return identityUser;
   97:         }
   98:  
   99:         ////////////////////////////////////////////////////////////////////////////
  100:  
  101:         /// <summary>
  102:         ///
  103:         /// </summary>
  104:         public static IdentityUser CreateUser(IdentityUser identityUser, string password, out IdentityResult identityResult)
  105:         {
  106:             var userStore = new UserStore<IdentityUser>(); // default UserStore constructor uses the default connection string named: DefaultConnection
  107:             var userManager = new UserManager<IdentityUser>(userStore);
  108:  
  109:             identityResult = userManager.Create(identityUser, password);
  110:  
  111:             identityUserList = null;
  112:  
  113:             return identityUser;
  114:         }
  115:  
  116:         ////////////////////////////////////////////////////////////////////////////
  117:  
  118:         /// <summary>
  119:         ///
  120:         /// </summary>
  121:         public static bool SignIn(string userName, string password)
  122:         {
  123:             bool signedIn;
  124:  
  125:             var userStore = new UserStore<IdentityUser>();
  126:             var userManager = new UserManager<IdentityUser>(userStore);
  127:             var identityUser = userManager.Find(userName, password);
  128:  
  129:             if (identityUser != null)
  130:             {
  131:                 var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
  132:                 var userIdentity = userManager.CreateIdentity(identityUser, DefaultAuthenticationTypes.ApplicationCookie);
  133:  
  134:                 authenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = false }, userIdentity);
  135:  
  136:                 signedIn = true;
  137:             }
  138:             else signedIn = false;
  139:  
  140:             return signedIn;
  141:         }
  142:  
  143:         ////////////////////////////////////////////////////////////////////////////
  144:  
  145:         /// <summary>
  146:         ///
  147:         /// </summary>
  148:         public static void SignOut()
  149:         {
  150:             var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
  151:  
  152:             authenticationManager.SignOut();
  153:         }
  154:  
  155:         ////////////////////////////////////////////////////////////////////////////
  156:  
  157:         /// <summary>
  158:         ///
  159:         /// </summary>
  160:         public static IdentityUser IdentityUserByUserName(string userName)
  161:         {
  162:             var userStore = new UserStore<IdentityUser>();
  163:             var userManager = new UserManager<IdentityUser>(userStore);
  164:  
  165:             var identityUser = (from q in userStore.Users where q.UserName == userName select q).SingleOrDefault();
  166:  
  167:             return identityUser;
  168:         }
  169:  
  170:         ////////////////////////////////////////////////////////////////////////////
  171:  
  172:         /// <summary>
  173:         /// 
  174:         /// </summary>
  175:         public static List<IdentityUser> IdentityUserList
  176:         {
  177:             get
  178:             {
  179:                 if (identityUserList == null || identityUserList.Count == 0)
  180:                 {
  181:                     lock (objectLock)
  182:                     {
  183:                         var userStore = new UserStore<IdentityUser>();
  184:                         var userManager = new UserManager<IdentityUser>(userStore);
  185:  
  186:                         identityUserList = userStore.Users.ToList();
  187:                     }
  188:                 }
  189:  
  190:                 return identityUserList;
  191:             }
  192:         }
  193:  
  194:         ////////////////////////////////////////////////////////////////////////////
  195:  
  196:         /// <summary>
  197:         ///
  198:         /// </summary>
  199:         public static bool ChangePassword(string userIdentityName, string currentPassword, string newPassword, string confirmNewPassword, out IdentityResult identityResult)
  200:         {
  201:             bool passwordChanged;
  202:  
  203:             var userStore = new UserStore<IdentityUser>();
  204:             var userManager = new UserManager<IdentityUser>(userStore);
  205:             var identityUser = userManager.FindByName(userIdentityName);
  206:  
  207:             if (identityUser != null)
  208:             {
  209:                 identityResult = userManager.ChangePassword(identityUser.Id, currentPassword, newPassword);
  210:  
  211:                 if (identityResult.Succeeded)
  212:                 {
  213:                     var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
  214:                     var userIdentity = userManager.CreateIdentity(identityUser, DefaultAuthenticationTypes.ApplicationCookie);
  215:  
  216:                     authenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = false }, userIdentity);
  217:  
  218:                     passwordChanged = true;
  219:                 }
  220:                 else passwordChanged = false;
  221:             }
  222:             else
  223:             {
  224:                 identityResult = new IdentityResult();
  225:  
  226:                 passwordChanged = false;
  227:             }
  228:  
  229:             return passwordChanged;
  230:         }
  231:  
  232:         /*
  233:         ////////////////////////////////////////////////////////////////////////////
  234: 
  235:         /// <summary>
  236:         ///
  237:         /// </summary>
  238:         public static bool UpdateUser(string userName, string oldPassword, string newPassword, string email, out Ia.Cl.Models.Result result)
  239:         {
  240:             bool b;
  241:             IdentityUser membershipUser;
  242: 
  243:             b = false;
  244:             result = new Ia.Cl.Models.Result();
  245: 
  246:             userList = null; // to force refresh in UserList
  247: 
  248:             membershipUser = System.Web.Security.Membership.GetUser(userName);
  249: 
  250:             if (oldPassword.Length > 0 && newPassword.Length > 0)
  251:             {
  252:                 b = membershipUser.ChangePassword(oldPassword, newPassword);
  253: 
  254:                 if (b)
  255:                 {
  256:                     result.AddSuccess(@"User """ + userName + @""" password updated.");
  257:                 }
  258:                 else
  259:                 {
  260:                     result.AddError(@"User """ + userName + @""" password not updated.");
  261:                 }
  262:             }
  263:             else
  264:             {
  265:                 result.AddError(@"Old and/or new password length is zero.");
  266:             }
  267: 
  268:             membershipUser.Email = email;
  269: 
  270:             System.Web.Security.Membership.UpdateUser(membershipUser);
  271: 
  272:             b = true;
  273: 
  274:             identityUserList = null;
  275: 
  276:             return b;
  277:         }
  278:         */
  279:  
  280:         ////////////////////////////////////////////////////////////////////////////
  281:  
  282:         /// <summary>
  283:         ///
  284:         /// </summary>
  285:         public static void DeleteUser(string userName, out IdentityResult identityResult)
  286:         {
  287:             var userStore = new UserStore<IdentityUser>();
  288:             var userManager = new UserManager<IdentityUser>(userStore);
  289:  
  290:             var identityUser = userManager.FindByName(userName);
  291:  
  292:             identityResult = userManager.Delete(identityUser);
  293:  
  294:             identityUserList = null;
  295:         }
  296:  
  297:         /*
  298:         ////////////////////////////////////////////////////////////////////////////
  299: 
  300:         /// <summary>
  301:         ///
  302:         /// </summary>
  303:         public static string MembershipCreateStatusText(MembershipCreateStatus membershipCreateStatus)
  304:         {
  305:             string s;
  306: 
  307:             switch (membershipCreateStatus)
  308:             {
  309:                 case MembershipCreateStatus.DuplicateEmail: s = "The e-mail address already exists in the database for the application. "; break;
  310:                 case MembershipCreateStatus.DuplicateProviderUserKey: s = "The provider user key already exists in the database for the application. "; break;
  311:                 case MembershipCreateStatus.DuplicateUserName: s = "The user name already exists in the database for the application. "; break;
  312:                 case MembershipCreateStatus.InvalidAnswer: s = "The password retrieval answer provided is invalid. "; break;
  313:                 case MembershipCreateStatus.InvalidEmail: s = "The e-mail address is not formatted correctly. "; break;
  314:                 case MembershipCreateStatus.InvalidPassword: s = "The password is not formatted correctly. "; break;
  315:                 case MembershipCreateStatus.InvalidProviderUserKey: s = "The provider user key is of an invalid type or format. "; break;
  316:                 case MembershipCreateStatus.InvalidQuestion: s = "The password retrieval question provided is invalid. "; break;
  317:                 case MembershipCreateStatus.InvalidUserName: s = "The user name provided is invalid. "; break;
  318:                 case MembershipCreateStatus.ProviderError: s = "The authentication provider returned an error. "; break;
  319:                 case MembershipCreateStatus.Success: s = "The user was successfully created. "; break;
  320:                 case MembershipCreateStatus.UserRejected: s = "The user creation request has been canceled. "; break;
  321:                 default: s = ""; break;
  322:             }
  323: 
  324:             ////////////////////////////////////////////////////////////////////////////
  325: 
  326:             /// <summary>
  327:             ///
  328:             /// </summary>
  329:             public static string GetErrorMessage(MembershipCreateStatus status)
  330:             {
  331:                 switch (status)
  332:                 {
  333:                     case MembershipCreateStatus.DuplicateUserName:
  334:                         return "Username already exists. Please enter a different user name.";
  335: 
  336:                     case MembershipCreateStatus.DuplicateEmail:
  337:                         return "A username for that e-mail address already exists. Please enter a different e-mail address.";
  338: 
  339:                     case MembershipCreateStatus.InvalidPassword:
  340:                         return "The password provided is invalid. Please enter a valid password value.";
  341: 
  342:                     case MembershipCreateStatus.InvalidEmail:
  343:                         return "The e-mail address provided is invalid. Please check the value and try again.";
  344: 
  345:                     case MembershipCreateStatus.InvalidAnswer:
  346:                         return "The password retrieval answer provided is invalid. Please check the value and try again.";
  347: 
  348:                     case MembershipCreateStatus.InvalidQuestion:
  349:                         return "The password retrieval question provided is invalid. Please check the value and try again.";
  350: 
  351:                     case MembershipCreateStatus.InvalidUserName:
  352:                         return "The user name provided is invalid. Please check the value and try again.";
  353: 
  354:                     case MembershipCreateStatus.ProviderError:
  355:                         return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
  356: 
  357:                     case MembershipCreateStatus.UserRejected:
  358:                         return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
  359: 
  360:                     default:
  361:                         return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
  362:                 }
  363:             }
  364: 
  365:             return s;
  366:         }
  367:         */
  368:  
  369:         ////////////////////////////////////////////////////////////////////////////
  370:  
  371:         /// <summary>
  372:         /// 
  373:         /// </summary>
  374:         public static List<IdentityRole> IdentityRoleList
  375:         {
  376:             get
  377:             {
  378:                 if (identityRoleList == null || identityRoleList.Count == 0)
  379:                 {
  380:                     lock (objectLock)
  381:                     {
  382:                         var roleStore = new RoleStore<IdentityRole>();
  383:                         var roleManager = new RoleManager<IdentityRole>(roleStore);
  384:  
  385:                         identityRoleList = roleStore.Roles.ToList();
  386:                     }
  387:                 }
  388:  
  389:                 return identityRoleList;
  390:             }
  391:         }
  392:  
  393:         ////////////////////////////////////////////////////////////////////////////
  394:  
  395:         /// <summary>
  396:         ///
  397:         /// </summary>
  398:         public static void CreateRole(string roleName)
  399:         {
  400:             CreateRole(roleName, out _);
  401:         }
  402:  
  403:         ////////////////////////////////////////////////////////////////////////////
  404:  
  405:         /// <summary>
  406:         ///
  407:         /// </summary>
  408:         public static void CreateRole(string roleName, out IdentityResult identityResult)
  409:         {
  410:             var roleStore = new RoleStore<IdentityRole>(); // default RoleStore constructor uses the default connection string named: DefaultConnection
  411:             var roleManager = new RoleManager<IdentityRole>(roleStore);
  412:  
  413:             var identityRole = new IdentityRole() { Name = roleName };
  414:  
  415:             CreateRole(identityRole, out identityResult);
  416:         }
  417:  
  418:         ////////////////////////////////////////////////////////////////////////////
  419:  
  420:         /// <summary>
  421:         ///
  422:         /// </summary>
  423:         public static void CreateRole(IdentityRole identityRole, out IdentityResult identityResult)
  424:         {
  425:             var roleStore = new RoleStore<IdentityRole>();
  426:             var roleManager = new RoleManager<IdentityRole>(roleStore);
  427:  
  428:             identityResult = roleManager.Create(identityRole);
  429:  
  430:             identityUserList = null;
  431:             identityRoleList = null;
  432:         }
  433:  
  434:         ////////////////////////////////////////////////////////////////////////////
  435:  
  436:         /// <summary>
  437:         ///
  438:         /// </summary>
  439:         public static bool RoleExists(string roleName)
  440:         {
  441:             var roleStore = new RoleStore<IdentityRole>();
  442:             var roleManager = new RoleManager<IdentityRole>(roleStore);
  443:  
  444:             var roleExists = roleManager.RoleExists(roleName);
  445:  
  446:             return roleExists;
  447:         }
  448:  
  449:         ////////////////////////////////////////////////////////////////////////////
  450:  
  451:         /// <summary>
  452:         ///
  453:         /// </summary>
  454:         public static void DeleteRole(string roleName, out IdentityResult identityResult)
  455:         {
  456:             var roleStore = new RoleStore<IdentityRole>();
  457:             var roleManager = new RoleManager<IdentityRole>(roleStore);
  458:  
  459:             var identityRole = roleManager.FindByName(roleName);
  460:  
  461:             identityResult = roleManager.Delete(identityRole);
  462:  
  463:             identityUserList = null;
  464:             identityRoleList = null;
  465:         }
  466:  
  467:         ////////////////////////////////////////////////////////////////////////////
  468:  
  469:         /// <summary>
  470:         ///
  471:         /// </summary>
  472:         public static void AddUserToRole(string userName, string roleName)
  473:         {
  474:             AddUserToRole(userName, roleName, out _);
  475:         }
  476:  
  477:         ////////////////////////////////////////////////////////////////////////////
  478:  
  479:         /// <summary>
  480:         ///
  481:         /// </summary>
  482:         public static void AddUserToRole(string userName, string roleName, out IdentityResult identityResult)
  483:         {
  484:             var userStore = new UserStore<IdentityUser>();
  485:             var userManager = new UserManager<IdentityUser>(userStore);
  486:  
  487:             var identityUser = userManager.FindByName(userName);
  488:  
  489:             identityResult = userManager.AddToRole(identityUser.Id, roleName);
  490:  
  491:             identityUserList = null;
  492:             identityRoleList = null;
  493:         }
  494:  
  495:         ////////////////////////////////////////////////////////////////////////////
  496:  
  497:         /// <summary>
  498:         ///
  499:         /// </summary>
  500:         public static void AddUserToRoleList(string userName, List<string> roleNameList, out IdentityResult identityResult)
  501:         {
  502:             var userStore = new UserStore<IdentityUser>();
  503:             var userManager = new UserManager<IdentityUser>(userStore);
  504:  
  505:             var identityUser = userManager.FindByName(userName);
  506:  
  507:             identityResult = userManager.AddToRoles(identityUser.Id, roleNameList.ToArray());
  508:  
  509:             identityUserList = null;
  510:             identityRoleList = null;
  511:         }
  512:  
  513:         ////////////////////////////////////////////////////////////////////////////
  514:  
  515:         /// <summary>
  516:         ///
  517:         /// </summary>
  518:         public static void RemoveUserFromRole(string userName, string roleName)
  519:         {
  520:             RemoveUserFromRole(userName, roleName, out _);
  521:         }
  522:  
  523:         ////////////////////////////////////////////////////////////////////////////
  524:  
  525:         /// <summary>
  526:         ///
  527:         /// </summary>
  528:         public static void RemoveUserFromRole(string userName, string roleName, out IdentityResult identityResult)
  529:         {
  530:             var userStore = new UserStore<IdentityUser>();
  531:             var userManager = new UserManager<IdentityUser>(userStore);
  532:  
  533:             var identityUser = userManager.FindByName(userName);
  534:  
  535:             identityResult = userManager.RemoveFromRole(identityUser.Id, roleName);
  536:  
  537:             identityUserList = null;
  538:             identityRoleList = null;
  539:         }
  540:  
  541:         ////////////////////////////////////////////////////////////////////////////
  542:  
  543:         /// <summary>
  544:         ///
  545:         /// </summary>
  546:         public static void RemoveUserFromRoleList(string userName, List<string> roleNameList, out IdentityResult identityResult)
  547:         {
  548:             var userStore = new UserStore<IdentityUser>();
  549:             var userManager = new UserManager<IdentityUser>(userStore);
  550:  
  551:             var identityUser = userManager.FindByName(userName);
  552:  
  553:             identityResult = userManager.RemoveFromRoles(identityUser.Id, roleNameList.ToArray());
  554:  
  555:             identityUserList = null;
  556:             identityRoleList = null;
  557:         }
  558:  
  559:         ////////////////////////////////////////////////////////////////////////////
  560:  
  561:         /// <summary>
  562:         ///
  563:         /// </summary>
  564:         public static List<IdentityUser> UsersInRoleList(string roleName)
  565:         {
  566:             var usersInRoleList = new List<IdentityUser>();
  567:  
  568:             var userStore = new UserStore<IdentityUser>();
  569:             var userManager = new UserManager<IdentityUser>(userStore);
  570:  
  571:             var roleStore = new RoleStore<IdentityRole>();
  572:             var roleManager = new RoleManager<IdentityRole>(roleStore);
  573:  
  574:             var role = (from r in roleManager.Roles where r.Name == roleName select r).SingleOrDefault();
  575:  
  576:             if (role != null)
  577:             {
  578:                 usersInRoleList = (from user in userManager.Users
  579:                                    where user.Roles.Any(r => r.RoleId == role.Id)
  580:                                    select user).ToList();
  581:             }
  582:  
  583:             return usersInRoleList;
  584:         }
  585:  
  586:         ////////////////////////////////////////////////////////////////////////////
  587:  
  588:         /// <summary>
  589:         ///
  590:         /// </summary>
  591:         public static bool IsUserInRole(string userName, string roleName)
  592:         {
  593:             bool userIsInRole;
  594:  
  595:             var userStore = new UserStore<IdentityUser>();
  596:             var userManager = new UserManager<IdentityUser>(userStore);
  597:  
  598:             var roleStore = new RoleStore<IdentityRole>();
  599:             var roleManager = new RoleManager<IdentityRole>(roleStore);
  600:  
  601:             var identityUser = userManager.FindByName(userName);
  602:  
  603:             if (identityUser != null)
  604:             {
  605:                 var identityRole = roleManager.FindByName(roleName);
  606:  
  607:                 userIsInRole = identityUser.Roles.Any(u => u.RoleId == identityRole.Id);
  608:             }
  609:             else userIsInRole = false;
  610:  
  611:             return userIsInRole;
  612:         }
  613:  
  614:         ////////////////////////////////////////////////////////////////////////////
  615:  
  616:         /// <summary>
  617:         ///
  618:         /// </summary>
  619:         public static List<IdentityRole> RolesForUserList(string userName)
  620:         {
  621:             var rolesForUserList = new List<IdentityRole>();
  622:  
  623:             var userStore = new UserStore<IdentityUser>();
  624:             var userManager = new UserManager<IdentityUser>(userStore);
  625:  
  626:             var roleStore = new RoleStore<IdentityRole>();
  627:             var roleManager = new RoleManager<IdentityRole>(roleStore);
  628:  
  629:             var identityUser = (from u in userManager.Users where u.UserName == userName select u).SingleOrDefault();
  630:  
  631:             if (identityUser != null)
  632:             {
  633:                 rolesForUserList = (from role in roleManager.Roles
  634:                                     where role.Users.Any(u => u.UserId == identityUser.Id)
  635:                                     select role).ToList();
  636:             }
  637:  
  638:             return rolesForUserList;
  639:         }
  640:  
  641:         /*
  642:         ////////////////////////////////////////////////////////////////////////////
  643: 
  644:         /// <summary>
  645:         ///
  646:         /// </summary>
  647:         public static List<LocalUser> InactiveSinceDateTimeUserList(DateTime dateTime)
  648:         {
  649:             LocalUser user;
  650:             MembershipUserCollection membershipUserCollection;
  651:             userList = new List<LocalUser>(initialUserListLength); // this is to prevent storage errors
  652: 
  653:             membershipUserCollection = Membership.GetAllUsers();
  654: 
  655:             foreach (IdentityUser mu in membershipUserCollection)
  656:             {
  657:                 if (mu.LastActivityDate < dateTime)
  658:                 {
  659:                     user = new LocalUser
  660:                     {
  661:                         ProviderUserKey = Guid.Parse(mu.ProviderUserKey.ToString()),
  662:                         UserName = mu.UserName,
  663:                         Email = (!mu.Email.Contains("kuix.com")) ? mu.Email : null
  664:                     };
  665: 
  666:                     userList.Add(user);
  667:                 }
  668:             }
  669: 
  670:             return userList.ToList();
  671:         }
  672:         */
  673:  
  674:         ////////////////////////////////////////////////////////////////////////////
  675:         ////////////////////////////////////////////////////////////////////////////
  676:     }
  677:  
  678:     ////////////////////////////////////////////////////////////////////////////
  679:     ////////////////////////////////////////////////////////////////////////////
  680: }