creating security token updates all user in membership table?http://forums.asp.net/t/1757882.aspx/1?creating+security+token+updates+all+user+in+membership+table+Thu, 01 Mar 2012 20:13:43 -050017578824775640http://forums.asp.net/p/1757882/4775640.aspx/1?creating+security+token+updates+all+user+in+membership+table+creating security token updates all user in membership table? <p>Hi All,</p> <p>I am trying to create a security token and when I run:</p> <pre class="prettyprint">token = SPSecurityContext.SecurityTokenForFormsAuthentication(base.AppliesTo, authProvider.MembershipProvider, authProvider.RoleProvider, username, password);</pre> <p>It updates every user entry I have in the aspnetdb membership table by changing the LastLoginDate to the current time for each record, not just the user that is passed as username in the above parameter.&nbsp; Does anyone know how to keep this to updating each record.&nbsp; I know it is that line of code for sure.&nbsp; I just dont understand what is it running in order to update each users record.&nbsp;</p> <p>Here is more code that surround this but that line above&nbsp;is in&nbsp;GetSecurityToken().&nbsp; I would really apprechiate any suggestions</p> <p>Thank you,</p> <p>Nici</p> <pre class="prettyprint"> protected void signInControl_LoggingIn(object sender, LoginCancelEventArgs e) { SecurityToken token = null; if (null != (token = GetSecurityToken())) { SPFederationAuthenticationModule fam = SPFederationAuthenticationModule.Current; fam.SetPrincipalAndWriteSessionToken(token); base.RedirectToSuccessUrl(); } } private void EstablishSessionWithToken(SecurityToken securityToken) { if (null == securityToken) { throw new ArgumentNullException("securityToken"); } SPFederationAuthenticationModule fam = SPFederationAuthenticationModule.Current; if (null == fam) { throw new ArgumentException(null, "FederationAuthenticationModule"); } fam.SetPrincipalAndWriteSessionToken(securityToken); } protected void signInControl_Authenticate(object sender, AuthenticateEventArgs e) { SecurityToken token = null; LoginControl formsLoginControl = sender as LoginControl; if (null != (token = GetSecurityToken())) { EstablishSessionWithToken(token); e.Authenticated = true; base.RedirectToSuccessUrl(); } } private SPIisSettings IisSettings { get { SPWebApplication webApp = SPWebApplication.Lookup(new Uri(SPContext.Current.Web.Url)); SPIisSettings settings = webApp.IisSettings[SPUrlZone.Default]; return settings; } } private SecurityToken GetSecurityToken() { SecurityToken token = null; SPIisSettings iisSettings = IisSettings; SPFormsAuthenticationProvider authProvider = iisSettings.FormsClaimsAuthenticationProvider; token = SPSecurityContext.SecurityTokenForFormsAuthentication(base.AppliesTo, authProvider.MembershipProvider, authProvider.RoleProvider, username, password); return token; } }</pre> <p>&nbsp;</p> 2012-01-10T16:32:40-05:004780599http://forums.asp.net/p/1757882/4780599.aspx/1?Re+creating+security+token+updates+all+user+in+membership+table+Re: creating security token updates all user in membership table? <p>Hi,</p> <p>SecurityTokenForFormsAuthentication&nbsp; function obtains a security token for a user authenticating through forms-based authentication.</p> <p><a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecuritycontext.securitytokenforformsauthentication.aspx">http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecuritycontext.securitytokenforformsauthentication.aspx</a></p> <p>Then get the MembershipUserCollection and foreach it.</p> <p><br> MembershipUserCollection users=Membership.GetAllUsers();</p> <p>MembershipUser objUser;</p> <p>foreach (objUser in objUserCollection)<br> {</p> <p>LastLoginDateLabel.Text = u.LastLoginDate.ToString();</p> <p>}<br> <br> <br> </p> 2012-01-13T06:25:33-05:004855576http://forums.asp.net/p/1757882/4855576.aspx/1?Re+creating+security+token+updates+all+user+in+membership+table+Re: creating security token updates all user in membership table? <p>Thank you very much for the reply.&nbsp; From that link it mentions validateuser.&nbsp; I ran that funtion alone it it works just fine.&nbsp; Only updating the one user I pass to it.&nbsp; Why would or is the securitytoken executing something other than my customMembershipProvider.ValidateUser()</p> <p>I am still struggling this, anything would help.&nbsp;</p> <p>Thank you,</p> <p>Nici</p> 2012-02-28T20:55:34-05:004859559http://forums.asp.net/p/1757882/4859559.aspx/1?Re+creating+security+token+updates+all+user+in+membership+table+Re: creating security token updates all user in membership table? <pre class="prettyprint">token = SPFormsUserNameSecurityTokenHandler.CreateSecurityToken(authProvider.MembershipProvider, authProvider.RoleProvider, username, password);</pre> <p>so creating the token this way fixed it</p> <p>&nbsp;</p> 2012-03-01T20:13:43-05:00