Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2012-03-24 : 06:24:15
|
| I have a portal where user need to login with username and password.How can I actually set the rights in my SQL query only user with this login can view their own profile?Can I do that? |
|
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2012-03-24 : 13:35:30
|
I assume once the user logs in you set some sort of authentication credential, such as a cookie, that stores the UserId.In your query to populate the profile entity you would just filter on that UserId.select firstName, lastName, gender, biofrom dbo.UserProfilewhere UserId = @UserId; Your question is rather general in nature. If the above is not helpful please provide a bit more detail about your problem so we can target our help :)Nathan Skerl |
 |
|
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2012-03-25 : 08:22:59
|
| I have a drop down list.So user with own login only can view own profile while other drop down name will be disable.Is this possible to use the query provided? |
 |
|
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2012-03-25 : 12:32:55
|
So, you want to show all names in the drop down but only enable the current user?You could return a flag to indicate the current user:select case when UserId = @UserId then 1 else 0 end as [isCurrentUser], firstName, ....from dbo.UserProfile... Honestly, this is probably something you should be doing in your middle tier though. You can do the same check while building the dropdown by comparing against the cookie. |
 |
|
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2012-03-25 : 22:03:14
|
| I still need the where condition right? or with the case is enough? |
 |
|
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2012-04-08 : 23:54:07
|
| Hmm..is still not working..Anybody could solve this? |
 |
|
|
|
|
|