I am having issues learning how to establish a Roles Function within this code that will assigned all Windows Authentication Users to a Role that is located in my SQL Database Table.
This is what I have so far.
namespace TMC { public class TMCUser { public int UserId { get; set; } public string Name { get; set; } public string UserName { get; set; } public string RoleName { get; set; } public Boolean IsActive { get; set; } Connection Conn = new Connection(); public TMCUser() { } public TMCUser(string userName) { using (SqlConnection conn = Conn.GetUtilitiesConnection) using (SqlCommand cmd = new SqlCommand("HBCC.usp_SelActiveUser", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@UserName", SqlDbType.NVarChar).Value = userName.Split('\\')[1]; if (conn.State != ConnectionState.Open) conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { UserId = (int)dr["UserId"]; Name = (string)dr["Name"]; UserName = (string)dr["UserName"]; RoleName = (string)dr["RoleName"]; IsActive = (bool)dr["IsActive"]; } conn.Close(); } } public Boolean AddUser() { return true; } public Boolean DisAbleUser(int userid) { return true; } // CREATE ROLE FUNCTION public TMCUser(string RoleName) { } }