本文整理汇总了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.";
}
}
}
示例2: Terminate
public void Terminate(UserIdentity userIdentity)
{
if (_serverSidePresentationSchemaTransfer.Contains(userIdentity))
_serverSidePresentationSchemaTransfer.Terminate(userIdentity);
else if (_serverSidePresentationTransfer.Contains(userIdentity))
_serverSidePresentationTransfer.Terminate(userIdentity);
}
示例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);
}
}
示例4: _lockingStorage_OnRemoveItem
private void _lockingStorage_OnRemoveItem(UserIdentity sender, ObjectKey key, LockingInfoWithCommunicationObject value)
{
if (RemoveItem != null)
{
RemoveItem(sender, key, value.LockingInfo);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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);
}
示例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);
}
}
示例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;
}
}
示例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();
}
示例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();
}
}
示例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();
}
}