I am trying to create a simple login application using WPF c#. I got the login part down but I cannot figure out how to create unique pages for individual users.If user "A" creates a new account, then he should have his own new profile form. This means every time I create a new user, a new profile form is generated and that new form is assigned to the user and no other user can make modification to that user's profile. For example: Skype profile. I am sure there are questions like this floating in stackoverflow but I can't find them. I would really appreciate if someone could guide me through this.
You're overthinking the problem. The form is the same for all the users. The content of each user's form varies. When the user logs in, your database should store some variables detailing that user. Simply set the forms controls to reflect the users details. Don't "create a new profile form".
Related
I have three levels of users in my website, Managers,employees and normal users. Each of them in different table in my database.
I created a log in form using login tool. Then I created connection and sessions.They work fine.
now my question is what is the best way to check the session in all pages (if it is manger, employee or user). it would be more useful if there is example :)
Thank you for your time.
Pretty traditional and simple, you could use this tried and true method.
Essentially you would use the UserData property of the authentication ticket to store the current users' roles. You can then obtain the data at any time from the current thread's principal.
I am using nopCommerce 3.50. And trying to make it a multi storied. Every user signup here will have there specific e-commerce like nopCommerce.
Main features I have to focus is:
Every user(store owner(1 store/user)) will have their own subdomain.
user's will have full control on their store.
They can change theme or configure any settings as an admin of
NopCommerce can.
So what I am thinking to do is:
Create a new project(mother project).
Link One NopCommerce Solution with it.
when a user signup there, they create a new database as nopcommerce.
Name database uniquely for the user.
store db name and all user info in mother project.
When user sign's in, get the user db from mother db and set the path to nopCommerce Solutions db-path.
when a user logs in, user is redirected to a subdomain.
and loads the respective database for the user using same server-side and client-side code.
Is it possible or there is any other better way to do this?
I have a small query.
I want to create user level authentication for a desktop application. Thats means, if:
1. Admin logs in, Admin get to see all options of the app
2. If user logs in, User gets to see only few details
My problem is I dont want to do this using a dropdown and choosing the User Type. I want to store the details in the database and once the user logs in, the new display window should show its contents according to the use type, i.e. Admin or User.
How can this be achieved. I am creating a Desktop application using C#.net.
Any help is appreciated.
Regards,
GenXCoders
In the desktop program:
using System.Security.Principal;
....
string adLogon = WindowsIdentity.GetCurrent().Name;
That will get you the current user.
In the database, something like:
create table Users (
ADLogon nvarchar(50), -- PK
IsAdmin bit -- in SQL Server this is the boolean type
)
Lookup the current user is the database, get their permission level.
Please tell me how to build Windows form Login .(not ASP.net)
. This login Should validate using not only windows Authentication method but also Database user.
How validate User name and password.
I used this type of Query for it
SELECT COUNT(*) FROM [Table Name] WHERE UserName = #username AND Password = #password;
If user available count >0
Above part handle code side.
using int x = Int32.Parse(commandObject.ExecuteScalar().ToString());
if(x > 0}
**log**
else
**fail**
How Can I do it professional and correct way?
Since you have the SQL already, all you need is a basic form, there's nothing special about a login form except that you hide the password, you can do that using the TextBox.PasswordChar property.
What do you mean by "Windows Authentication"? You could read the logged in User from the Environment and prefill the user-textfield with this value.
tbUserName = Environment.UserName;
After the User has entered his password, your setup dictates what to do. Is the Password Database Hashed (MD5, SHA1) or Verbatim? If so, hash the entered Password - or don't if it isn't.
You could use those two strings to select entities from your DataSource using the technology of your preference (e.g. ADO.Net). If no results are returned, the login was faulty. Remember: That way you won't be able to tell whether just the password or the user or both were wrong.
"Professional and correct way"
This can depend on what you application does, do you allow any kinda content to be seen or the first think should be login?
If yes:
Create a Window Form with your login screen
upon "login" button is clicked, check the sql the way you want
if ok, close that window and do a form.Show() the main window of your application
else, just give a good reason that you don't allow the user to proceed
if windows authentication, you need to check if that windows user can access it, do the same procedure but you do act upon formLogin.Active for example, and ask for credentials if that Windows User is not a valid user and do the above process again.
As an example, SuperOffice CRM 6 Application for windows, have this login form:
alt text http://www.balexandre.com/temp/2010-09-09_1557.png
I hope it helps to get an idea.
If you were asking about code only, then you already have good answers.
Just a thought...
Have your login as the first screen your user visits.
If they pass, then show the main app form and hide the login.
If they fail, simply display a message stating that.
It's not like web apps where a user can type in a url and try to get to any page they want to.
You have FULL CONTROL :)
I am creating a web application using Form Authentication of Asp.Net with C# and back end Sql Server. Here in my application administrator login and creates new users. I am using the create user wizard under login controls. My problem is when the new user is created by Admin he is automatically logged out and logged in with new user credentials which he has just created. Any help would be highly appreciated.
The CreateUserWizard has a property called LoginCreatedUser. Set it to false, and this will solve the issue.
Perhaps that wizard is meant for new users so that they can create their own account when they visit the site. it is not intended to work the way your admin is using it.