Click here to Skip to main content
15,845,469 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,

i wana work on a windows forms application using c# that several users can work with different roles, for example 3 roles ,that "A role" only to access some parts of the program and cannot see and access it and "B role" can acess to entire of application, but some parts are just right to access and view, "C role" full access to all parts of the Application i have these roles and users in a database (sql server).

whats a good way for make this application?

thanks in advance...
Posted
Comments
avinasoni 23-Dec-14 2:02am    
i m working on a web project on asp.net using c# where different user has different access permission and these permission has to be set up by masteradmin after the delivery of project. we have 15 pages with some different functionality and admin has to allow the functionality using checkbox for rights like only add only view, only print, only import or export the data. please help me to achieve it..

Hi,

One solution might be:
Have a login page initially where you authenticate the user by his id and password and check whether he has role A,B or C.
Role C in your case will be the Admin.
As the user is authenticated as A or B or C, redirect them to separate win forms having desired functionalities as you need.
Ex: Role A can change his password, view the courses he has enrolled with, while role C being an admin can view all the roles, edit the roles, edit the courses, view/edit the fees paid by the other users and stuffs.

The key here is to have a common login page, authenticate a user based upon his id and password and check in ur DB whether what role he has, and then redirect them to their individual forms.

Hope it helps.

Regards
Anurag
 
Share this answer
 
Comments
stellus 5-Mar-13 7:34am    
thanks for comments,
can you have drop a sample code or else any related link which you have ?
please let me know..

thanks.
Member 10217711 15-Sep-13 6:16am    
Hi,
can you please send me also the code on id binudesai009@gmail.com
Thanks
Anurag Sinha V 5-Mar-13 11:27am    
hi...let me see mate..i had done a similar kinda thing..le me search n i will send u...
cn u drop ur email id here?coz its gonna be an application n pretty big...

anurag
Anurag Sinha V 15-Sep-13 11:36am    
sent..check your inbox..
-anurag
Abbas Lakhani 25-Nov-14 12:57pm    
meabbas92@yahoo.com pls send me too
Although RoleProvider and Membership provider functionality is meant to be used with asp.net, you can use it with WindowsForms applications too, see this article: http://mkdot.net/community/mknetug/mk_sp/b/zzl/archive/2008/04/09/using-the-built-in-asp-net-role-provider-in-windows-forms-or-console-applications.aspx[^]. The rest will be much the same as in case of asp.net, and as there is a built-in ready to use SqlRoleProvider, it is straightforward to use it: http://msdn.microsoft.com/en-us/library/ff647401.aspx[^]
 
Share this answer
 
we can give you a "ready" peace of code to you, i prefer if you dig in that to understand more about what we call : Membership management, specially if you want to do it the right way, personally i had that problem before and i was looking like you for a ready peace of code, but i realized after reading articles and documentation that there is a lot to understand about that.
So first there are many solutions you can use, one of them is Asp.Net Membership, but there are others so you need to know them and find what helps you the most, but i will talk about ASP.Net Membership little !
So what you need to understand, is to : "use technology made by professional ! instead of reinventing the wheel", avoid creating your own managing system.
Asp.Net Membership provide you what you need...
here is a link where i started : VIDEO ON YOUTUBE[^]

what you need to understand is that, this may be a Web Application example ! but it's a simple Database...just like any other Database and some code ! so you can use it in a winform application ! (just configure your App.Config file so it will point to the right Database : try to understand what : Providers means what is their job)
this is an example of code you can use to check for example if a this is a use :

C#
//Check if the tbLogin and tbPassword are for a Member or not :
if (Membership.ValidateUser(tbLogin.Text, tbPassword.Text))
{
    MessageBox.Show("Connected");
}
// treatment if authenticated

else
{
    MessageBox.Show("Not Connected");
}
this.Dispose();


or this peace of code to get MembershipUser object from the User Name :

C#
private MembershipUser GetUserMembershipFromUserName(string userName)
        {
            var mu = Membership.GetUser(userName);
            return (mu);
        }


and from that MemebershipUser Object you can get anythg you want : ID, Email, Role...etc!
you can use this peace of code in each loading of winform to keep/redirect the user !
anyway there is so much to talk about in this topic this is why i wanted you to ready more about it, sorry if my English is not very good, if you need more help let me know, good luck :)
 
Share this answer
 
Comments
[no name] 27-Jan-14 1:49am    
i want how we can make login on my window application which username=username of administrator group and password=password of such admin group ..........
plz sent me code or help...
Hi, sorry for replying late,
so here is the almost all what you need : Create a user, delete a user, find the user by the e-mail...etc

MembershipProvider Methods

Good luck.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900