当前位置: 首页>>代码示例>>C#>>正文


C# UserIdentity类代码示例

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


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


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