• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# UserIdentity类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中UserIdentity的典型用法代码示例。如果您正苦于以下问题:C# UserIdentity类的具体用法?C# UserIdentity怎么用?C# UserIdentity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UserIdentity类属于命名空间,在下文中一共展示了UserIdentity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: button1_Click

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (textBoxEmail.Text.Length == 0)
            {
                errormessage.Text = "Enter an email.";
                textBoxEmail.Focus();
            }
            else if (!textBoxEmail.Text.Equals("1") && (!Regex.IsMatch(textBoxEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")))
            {
                errormessage.Text = "Enter a valid email.";
                textBoxEmail.Select(0, textBoxEmail.Text.Length);
                textBoxEmail.Focus();

            }
            else if ((comboBoxDatabase.SelectedValue as ListBoxItem) == null)
            {
                errormessage.Text = "Select database from provided list";
            }
            else
            {
                // Save global variables with connection string to database selected from combo for future nhibernate use when initiation session
                if ((comboBoxDatabase.SelectedValue as ListBoxItem).Content.ToString().Equals("mydb"))
                {
                    Application.Current.Properties["HOSTNAME"] = "localhost";
                    Application.Current.Properties["DBSID"] = "mydb";
                    Application.Current.Properties["DBUSER"] = "root";
                    Application.Current.Properties["DBPASSWORD"] = "varase";
                }
                else if ((comboBoxDatabase.SelectedValue as ListBoxItem).Content.ToString().Equals("mydbTest"))
                {
                    Application.Current.Properties["HOSTNAME"] = "localhost";
                    Application.Current.Properties["DBSID"] = "mydbTest";
                    Application.Current.Properties["DBUSER"] = "root";
                    Application.Current.Properties["DBPASSWORD"] = "varase";
                }

                string email = textBoxEmail.Text;
                string password = passwordBox1.Password;
                UserIdentity userInstance = new UserIdentity();

                bool isUserAuthenticated = nhibernategateway.ValidateUserCredentials(email,password, out userInstance);

                if (isUserAuthenticated)
                {
                    Application.Current.Properties["LoggedUserID"] = userInstance.id.ToString();
                    Application.Current.Properties["LoggedUserEmail"] = userInstance.email.ToString();

                    MainConsole myMainWindow = new MainConsole();
                    System.Windows.Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
                    System.Windows.Application.Current.MainWindow = myMainWindow;

                    myMainWindow.Show();
                    Close();
                }
                else
                {
                    errormessage.Text = "Please enter existing Email/Password.";
                }
            }
        }
开发者ID:sergeiton2,项目名称:WeRSupportWebSite2,代码行数:60,代码来源:Login.xaml.cs


示例2: Terminate

 public void Terminate(UserIdentity userIdentity)
 {
     if (_serverSidePresentationSchemaTransfer.Contains(userIdentity))
         _serverSidePresentationSchemaTransfer.Terminate(userIdentity);
     else if (_serverSidePresentationTransfer.Contains(userIdentity))
         _serverSidePresentationTransfer.Terminate(userIdentity);
 }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:7,代码来源:PresentationExportHelper.cs


示例3: btnLogon_Click

        protected void btnLogon_Click(object sender, EventArgs e)
        {
            if (AuthMod.ValidateUser(txtInputBrukernavn.Text, txtInputPassord.Text)) {
            FormsAuthenticationTicket tkt = new FormsAuthenticationTicket(1, txtInputBrukernavn.Text, DateTime.Now,
               DateTime.Now.AddMinutes(30), chkRememberMe.Checked, "AuthentiCationCookie");
            string cookiestr = FormsAuthentication.Encrypt(tkt);
            HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
            if (chkRememberMe.Checked)
               authCookie.Expires = tkt.Expiration;
            authCookie.Path = FormsAuthentication.FormsCookiePath;

            string encTicket = authCookie.Value;
            if (!String.IsNullOrEmpty(encTicket)) {
               var ticket = FormsAuthentication.Decrypt(encTicket);
               UserIdentity id = new UserIdentity(ticket, AuthMod);
               var userRoles = AuthMod.GetRolesForUser(id.Name);
               var prin = new GenericPrincipal(id, userRoles);
               HttpContext.Current.User = prin;
            }
            System.Threading.Thread.CurrentPrincipal = HttpContext.Current.User;
            HttpContext.Current.Cache.Insert("customPrincipal", HttpContext.Current.User);

            Response.Cookies.Add(authCookie);
            FormsAuthentication.RedirectFromLoginPage(txtInputBrukernavn.Text, chkRememberMe.Checked);
             } else {
            logonErrorSpan.Visible = true;
            //Response.Redirect("~/Public/Login.aspx", true);
             }
        }
开发者ID:itnifl,项目名称:Blodbanken,代码行数:29,代码来源:Login.aspx.cs


示例4: _lockingStorage_OnRemoveItem

 private void _lockingStorage_OnRemoveItem(UserIdentity sender, ObjectKey key, LockingInfoWithCommunicationObject value)
 {
     if (RemoveItem != null)
     {
         RemoveItem(sender, key, value.LockingInfo);
     }
 }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:7,代码来源:LockingService.cs


示例5: Send

 public FileSaveStatus Send(UserIdentity userIdentity, FileTransferObject obj)
 {
     if (_serverSidePresentationSchemaTransfer.Contains(userIdentity))
         return _serverSidePresentationSchemaTransfer.Send(userIdentity, obj);
     else if (_serverSidePresentationTransfer.Contains(userIdentity))
         return _serverSidePresentationTransfer.Send(userIdentity, obj);
     return FileSaveStatus.Abort;
 }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:8,代码来源:PresentationExportHelper.cs


示例6: Receive

 public FileTransferObject? Receive(UserIdentity userIdentity, string resourceId)
 {
     if (_serverSidePresentationSchemaTransfer.Contains(userIdentity))
         return _serverSidePresentationSchemaTransfer.Receive(userIdentity, resourceId);
     else if (_serverSidePresentationTransfer.Contains(userIdentity))
         return _serverSidePresentationTransfer.Receive(userIdentity, resourceId);
     return null;
 }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:8,代码来源:PresentationExportHelper.cs


示例7: Deauthenticate

            // deauthenticates the user given by the input session
            public void Deauthenticate(ref UserSession session)
            {
                // gets the sessions authenticated id (possibly null)
                var authenticatedId = session?.Identity().AuthenticatedId;
                if (authenticatedId == null) return;

                // deauthenticates the current user
                var userId = new UserIdentity(authenticatedId.GetValueOrDefault(), "");
                session = new UserSession(userId, false);
            }
开发者ID:joachimda,项目名称:I4PRJ,代码行数:11,代码来源:Authenticator.cs


示例8: MapIdentity

        public int MapIdentity(string userid, string identytProvider, string identityValue)
        {
            var mapping = new UserIdentity();
            mapping.UserId = new Guid(userid);
            mapping.IdentityProvider = identytProvider;
            mapping.IdentityValue = identityValue;
            _context.AddToUserIdentities(mapping);
            _context.SaveChanges();

            return mapping.IdentityID;
        }
开发者ID:darioquintana,项目名称:src,代码行数:11,代码来源:IdentityRepository.cs


示例9: Receive

 public FileTransferObject? Receive(UserIdentity userIdentity, string resourceId)
 {
     try
     {
         return _serverSideGroupFileTransfer.Receive(userIdentity, resourceId);
     }
     catch(Exception ex)
     {
         _config.EventLog.WriteError(string.Format("ConfigurationExportHelper.Receive: {0}", ex));
         return null;
     }
 }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:12,代码来源:ConfigurationExportHelper.cs


示例10: LockingService

        //private readonly LockingNotifier _notifier = new LockingNotifier();

        public LockingService(UserIdentity systemUser, IEventLogging log)
        {
            _systemUser = systemUser;
            _log = log;
            _timer = new Timer(_interval);
            _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed);
            _timer.Start();
            _lockingStorage = new LockingStorage();
            _lockingStorage.OnAddItem += _lockingStorage_OnAddItem;
            _lockingStorage.OnRemoveItem += _lockingStorage_OnRemoveItem;
            //_lockingStorage.OnAddItem += new TechnicalServices.Common.StorageAction<ObjectKey, LockingInfo>(_notifier.SubscribeForMonitor);
            //_lockingStorage.OnRemoveItem +=new TechnicalServices.Common.StorageAction<ObjectKey,LockingInfo>(_notifier.UnSubscribeForMonitor);
        }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:15,代码来源:LockingService.cs


示例11: ServerSideFileReceive

        public ServerSideFileReceive(UserIdentity userIdentity, /*IResourceEx<T> resourceEx*/IFileInfoProvider provider)
        {
            //_resourceEx = resourceEx;
            _userIdentity = userIdentity;
            //Resource = resource;
            _provider = provider;
            //_resourceFileInfo = _resource.ResourceInfo as ResourceFileInfo;
            if (OperationContext.Current != null && OperationContext.Current.Channel != null)
            {
                _communicationObject = OperationContext.Current.Channel;
                _communicationObject.Faulted += new EventHandler(Abort);
            }

        }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:14,代码来源:ServerSideFileReceive.cs


示例12: Authenticate

            // authenticates and provides a user with a corresponding session
            public UserSession Authenticate(string email, string password)
            {
                // returns null if user could not be authenticated based on the input   
                using (var db = new SmartPoolContext())
                {
                    // queries the database for users with the specified input
                    var userQuery = from users in db.Users
                        where users.Email == email && users.Password == password
                        select users.UserId;

                    // checks to see whether the input was matched by the query
                    var userId = new UserIdentity(userQuery.First(), password);
                    return userQuery.Any() ? new UserSession(userId, true) : null;
                }
            }
开发者ID:joachimda,项目名称:I4PRJ,代码行数:16,代码来源:Authenticator.cs


示例13: PresentationListController

        public PresentationListController(PresentationListForm AView)
        {
            _instance = this;
            view = AView;

            identity = Thread.CurrentPrincipal as UserIdentity;

            DesignerClient.Instance.PresentationNotifier.OnObjectLocked += new EventHandler<NotifierEventArg<LockingInfo>>(PresentationNotifier_OnObjectLocked);
            DesignerClient.Instance.PresentationNotifier.OnObjectUnLocked += new EventHandler<NotifierEventArg<LockingInfo>>(PresentationNotifier_OnObjectUnLocked);
            DesignerClient.Instance.PresentationNotifier.OnPresentationAdded += new EventHandler<NotifierEventArg<PresentationInfo>>(PresentationNotifier_OnPresentationAdded);
            DesignerClient.Instance.PresentationNotifier.OnPresentationDeleted += new EventHandler<NotifierEventArg<PresentationInfo>>(PresentationNotifier_OnPresentationDeleted);
            DesignerClient.Instance.PresentationNotifier.OnObjectChanged += new EventHandler<NotifierEventArg<IList<ObjectInfo>>>(PresentationNotifier_OnObjectChanged);

            DesignerClient.Instance.PresentationWorker.SubscribeForGlobalMonitoring();
        }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:15,代码来源:PresentationListController.cs


示例14: DeleteSource

 public override bool DeleteSource(UserIdentity sender, DeviceResourceDescriptor descriptor)
 {
     _sync.AcquireWriterLock(Timeout.Infinite);
     try
     {
         bool isSuccess = base.DeleteSource(sender, descriptor);
         if (isSuccess)
             _cache.DeleteResource(descriptor);
         return isSuccess;
     }
     finally
     {
         _sync.ReleaseWriterLock();
     }
 }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:15,代码来源:DeviceSourceDALCaching.cs


示例15: DeletePresentation

        public override bool DeletePresentation(UserIdentity sender, string uniqueName)
        {
            _sync.AcquireWriterLock(Timeout.Infinite);
            try
            {
                bool isSuccess = base.DeletePresentation(sender, uniqueName);
                if (isSuccess)
                    _cache.Delete(ObjectKeyCreator.CreatePresentationKey(uniqueName));
                return isSuccess;
            }
            finally
            {
                _sync.ReleaseWriterLock();
            }

        }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:16,代码来源:PresentationDALCaching.cs


示例16: RebuildUserFromCookies

        /// <summary>
        /// Authenticate the request.
        /// Using Custom Forms Authentication since I'm not using the "RolesProvider".
        /// Roles are manually stored / encrypted in a cookie in <see cref="FormsAuthenticationService.SignIn"/>
        /// This takes out the roles from the cookie and rebuilds the Principal w/ the decrypted roles.
        /// http://msdn.microsoft.com/en-us/library/aa302397.aspx
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public static void RebuildUserFromCookies()
        {
            string cookieName = FormsAuthentication.FormsCookieName;
            HttpCookie authCookie = HttpContext.Current.Request.Cookies[cookieName];
            if (null == authCookie) return;

            FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);
            String[] roles = authTicket.UserData.Split(new char[] { ',' });

            // Create an Identity object
            IIdentity id = new UserIdentity(0, authTicket.Name, "Forms", true);
            IPrincipal principal = new UserPrincipal(0, authTicket.Name, roles, id);

            // Attach the new principal object to the current HttpContext object
            HttpContext.Current.User = principal;
        }
开发者ID:jespinoza711,项目名称:ASP.NET-MVC-CMS,代码行数:25,代码来源:SecurityHelper.cs


示例17: SavePresentation

 public override bool SavePresentation(UserIdentity sender, Presentation presentation)
 {
     _sync.AcquireWriterLock(Timeout.Infinite);
     try
     {
         bool isSuccess = base.SavePresentation(sender, presentation);
         if (isSuccess)
             _cache.Add(ObjectKeyCreator.CreatePresentationKey(presentation),
                 presentation);
         return isSuccess;
     }
     finally
     {
         _sync.ReleaseWriterLock();
     }
 }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:16,代码来源:PresentationDALCaching.cs


示例18: LoginStatusChange

 public void LoginStatusChange(UserIdentity user, LogOnStatus newLoginStatus)
 {
     switch (newLoginStatus)
     {
         case LogOnStatus.LogOn:
             _list.Add(user);
             break;
         case LogOnStatus.LogOff:
             //int index = _list. FindIndex(value => value.Name == user.Name);
             //if (index >= 0)
             //    _list.RemoveAt(index);
             _list.Remove(user);
             break;
         default:
             throw new ApplicationException("Ненене Дэвид Блейн ненене");
     }
 }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:17,代码来源:LoginServiceCallback.cs


示例19: GetPresentationStatusDescr

        public static string GetPresentationStatusDescr(string Name, PresentationStatus status, UserIdentity id)
        {
            StringBuilder sb = new StringBuilder();
            string userName = string.Empty;
            if ((id != null) && (id.User != null))
                userName = string.IsNullOrEmpty(id.User.FullName) ? id.User.Name : id.User.FullName;
            switch (status)
            {
                case PresentationStatus.Deleted: sb.Append("Сценарий уже удален"); break;
                case PresentationStatus.LockedForEdit: sb.AppendFormat("Сценарий заблокирован пользователем {0} для редактирования", userName); break;
                case PresentationStatus.LockedForShow: sb.AppendFormat("Сценарий заблокирован пользователем {0} для показа", userName); break;
                case PresentationStatus.SlideLocked: sb.Append("Сцена сценария заблокирована"); break;
                case PresentationStatus.Unknown: sb.Append("Неизвестно"); break;
                case PresentationStatus.AlreadyLocallyOpened: sb.Append("Сценарий уже открыт в другом экземпляре Дизайнера"); break;
            }

            return sb.ToString();
        }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:18,代码来源:PresentationStatusInfo.cs


示例20: SaveSource

        public override DeviceResourceDescriptor SaveSource(UserIdentity sender, DeviceResourceDescriptor resourceDescriptor, Dictionary<string, string> fileDic)
        {
            _sync.AcquireWriterLock(Timeout.Infinite);
            try
            {

                DeviceResourceDescriptor stored
                    = base.SaveSource(sender, resourceDescriptor, fileDic);
                if (null != stored)
                {
                    _cache.AddResource(stored);
                }
                return stored;
            }
            finally
            {
                _sync.ReleaseWriterLock();
            }
        }
开发者ID:AlexSneg,项目名称:VIRD-1.0,代码行数:19,代码来源:DeviceSourceDALCaching.cs



注:本文中的UserIdentity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UserInfo类代码示例发布时间:2022-05-24
下一篇:
C# UserId类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap