public override string[] GetRolesForUser(string username) { WCFSimpleAccess SecurityAccess = new WCFSimpleAccess(); SecurityAccess.ConnectionStringName = "AltErlaaInfoConnectionString"; DataSet RollDataSet = SecurityAccess.GetCommonDataSet ("select RoleName from aspnet_Roles where RoleID in " + "(select RoleId from aspnet_UsersInRoles where UserID in " + "(select UserID from aspnet_Membership where ApplicationID in " + "(select ApplicationID from aspnet_Applications where LoweredApplicationName = '" + ApplicationName.ToLower () + "')" + "and UserID in (select UserID from aspnet_Users where LoweredUserName = '******')))"); RoleList = new List<string> (); foreach (DataRow RollRow in RollDataSet.Tables["aspnet_Roles"].Rows) RoleList.Add(RollRow ["RoleName"].ToString ()); WPMediaApplicationState.Instance.Properties["UserName"] = username; WPMediaApplicationState.Instance.Properties["Rollen"] = RoleList.ToArray(); return RoleList.ToArray(); }
public override bool ValidateUser(string UserName, string PassWord) { ClientFormsAuthenticationCredentials ReturnCredentials = null; if ((String.IsNullOrEmpty(UserName)) && (String.IsNullOrEmpty(PassWord))) { IClientFormsAuthenticationCredentialsProvider LoginWindow = new CommonLogin() as IClientFormsAuthenticationCredentialsProvider; ReturnCredentials = LoginWindow.GetCredentials(); if (ReturnCredentials == null) { return false; } UserName = ReturnCredentials.UserName; PassWord = ReturnCredentials.Password; } WMB.WPMediaApplicationState.Instance.Properties ["UserName"] = CVM.LoginHandler.DefaultUsedUserName; LoginHandler.CreateSecurityToken(WMB.WPMediaApplicationState.Instance.Properties["UserName"].ToString ()); GenericIdentity Ident = new GenericIdentity(CVM.LoginHandler.DefaultUsedUserName); Thread.CurrentPrincipal = new GenericPrincipal(Ident, CVM.LoginHandler.DefaultRollen); WCFSimpleAccess SecurityAccess = new WCFSimpleAccess(); SecurityAccess.ConnectionStringName = "AltErlaaInfoConnectionString"; DataSet User = SecurityAccess.GetCommonDataSet ("select UserId, PasswordSalt from aspnet_Membership where UserID in " + "(select UserId from aspnet_Users where LoweredUserName = '******') " + "and ApplicationID in (select ApplicationID from aspnet_Applications where LoweredApplicationName = '" + ApplicationName.ToLower( ) + "')"); if (User.Tables ["aspnet_Membership"].Rows.Count < 1) return false; ActuallUserID = (Guid) User.Tables["aspnet_Membership"].Rows[0]["UserID"]; String EncodedBase64Password = EncodePassword(PassWord, User.Tables ["aspnet_Membership"].Rows [0] ["PasswordSalt"].ToString ()); DataSet UserPWD = SecurityAccess.GetCommonDataSet ("select Password from aspnet_Membership where UserID = '" + ActuallUserID.ToString( ) + "'"); if ((UserPWD.Tables ["aspnet_Membership"] == null) || (UserPWD.Tables ["aspnet_Membership"].Rows.Count != 1) || (UserPWD.Tables ["aspnet_Membership"].Rows [0] ["Password"].ToString () != EncodedBase64Password)) { Thread.CurrentPrincipal = null; return false; } WMB.WPMediaApplicationState.Instance.Properties["UserName"] = UserName; LoginHandler.CreateSecurityToken(WMB.WPMediaApplicationState.Instance.Properties["UserName"].ToString()); Ident = new GenericIdentity(UserName); Thread.CurrentPrincipal = new GenericPrincipal(Ident, CVM.LoginHandler.DefaultRollen); LoginHandler.CreateSecurityToken(UserName); return true; }