WPF C#-multiple user privileges -
i want display different menu different users using c# wpf.
also have multiple login oracle database.
i want control user privileges through c#.
aravindhan – first need have in place authentication , authorization process in place. so, how authentication:
http://blog.magnusmontin.net/2013/03/24/custom-authorization-in-wpf/
basically, need implement interfaces described on link above .net provides you. when on iauthenticationservice ->authenticateuser method, have provide oracle implementation that.
the implementation similar snippet below:
public user authenticateuser(string username, string cleartextpassword){ var list<internaluserdata> _users = getuserslist(); internaluserdata userdata = _users.firstordefault(u => u.username.equals(username) && u.hashedpassword.equals(calculatehash(cleartextpassword, u.username))); if (userdata == null) throw new unauthorizedaccessexception("access denied. please provide valid credentials."); return new user(userdata.username, userdata.email, userdata.roles); } public list<internaluserdata> getuserslist(){ string sql = "select username, email, password, userole user"; command.commandtext = sql; var list< internaluserdata> listusers = new list< internaluserdata>(); oracledatareader reader = command.executereader(); while (reader.read()) { listusers.add( new internaluserdata((string)reader["username"], (string)reader["email"], (string)reader["password"],new string[] { (string)reader["userole "]}) } return listusers; }
Comments
Post a Comment