.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

ScaffoldTable(false) if user is not in the admin role.

Posted By:      Posted Date: October 06, 2010    Points: 0   Category :ASP.Net

Hi guys,

I my dynamic data application, I made ScaffoldTable(false) on some of the table in a seperate partial classes. I am using linq to sql classes for my tables and Also I am using sql membership on my application.

what I want to do is that I need to make the following table's ScaffoldTable as false, if the user is not in the admin role. How can I do that ?


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Configuration;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Xml.Linq;
using System.Linq.Expressions;
using System.Reflection;

/// <summary>
/// Summary description for CategoriesPhoto
/// </summary>

public partial class CategoriesPhoto
public class CategoriesPhotoMetaData


View Complete Post

More Related Resource Links

Restrict user with sys admin role to execute a query


Hi All


I want to restrict  a user with sys admin server role to execute a query. or is there any possibility to drop the query before it get executed (after parsing). I know i can do this using SSMS SET NOEXEC ON | OFF in Query Analyzer.

But how can i implement this when ever sysadmin user executes a particular query.


Mohd Sufian www.sqlship.wordpress.com Please mark the post as Answered if it helped.

Need help with setting up SQL Server 2008 for role/user management


I've posted my problem in a few other categories.  Sorry for that.  I didn't see the security category until now.

I'm trying to use ASP.NET's built-in role/user management for a couple ASP.NET MVC 2 sites.  I'm using the MVCMusicStore as my guide.  I click on the Configuration Tool as the tutorial suggests, which launches the site administration page.  Unfortunately when I click on the security tab, I get an error that it cannot connect to the data store.  Attempting to test the AspNetSqlProvider gives me a similar error.

I've run the aspnet_regsql program as the error message suggested, and I have a role/user management database ready to go on the server.  The proper tables are constructed, and all that.  The configuration tool still doesn't see the data store.

As a test, I ran the MVCMusicStore demo in the debugger.  Its role/user management functionality worked.  I was able to add myself as a customer, and add/remove items from my cart with no errors or exceptions.  However, when I attempted to access its security tab in the configuration tool, I received the same error as I get for my own project.  How is it possible that role/user management works, but the configuration tool cannot change its settings?

Any suggestions on how I can get the configuration t

How to determine if current SQL User is admin or owner?

I wish to determine, from my C# application, if the current user has admin or owner rights to the database they are connected to. I beleive I have all the information required: Servername Database name Windows/Database auth username (If database auth) password (if database auth) I'm trying to find a way that using the smo objects (smo.user), but as of yet I cant quite work it out: - How to get the appropriate user - How to determine if that user is an admin/owner. Any tips would be appreciated. If I have posted to the wrong forum, let me know - I couldnt find one that was obviously more appropriate. Thanks.

How to check if a given user is local admin or not

Hi, How to check if a user (may be domain user also) is part of local administrators group or not? Note I am NOT talking about checking of current logged in user. I should send the username & passowrd of any user (may or may not be domain user) & that should flag me whether that user is local admin or not. Please help.

How to let a non admin business user run a replication snapshot job?

According to the msdn library, I would have to give the non admin user (User1) SQLAgentUserRole privileges. But it also says that it has to be a local job and not a multi server job. Is the snapshot agent job a local or multi server job? Considering the snapshot agent is a local job and i make USER1 the owner of that job. He should be able to run the job rite? I need to give USER1 the ability to run sp_start_job to start the snapshot agent ONLY! (and not any other jobs). So what are the steps to do this? I also read that the only way to achieve this is by creating a proxy account? Is there an article somewhere that best describes this?  

asp.net,c#,user role and rights,menu

hi friendsi want to develope general code or module or structure of web application wich handle multiple user ,their role and right, and according to their rights and role menu will be display.so i can integreate it in any website. kindly provide me solution for asp.net 3.5,C# working environment, and sqlserver 2005 environment.what is the structure for database? i want only one database not asp.net database. can i make login control type assembly(dll)?how?Thanking you 

Need to set "ValidateRequest" on the basis of user role

I am trying to implement a code which will switch Validation request on the page on the basis of user role. If accessed by power user, it should allow html entries in textboxes otherwise restrict. I want to implement something like below..I would really appreciate if proper idea/code is shared. if (Page.IsPostBack == false) { if (Session["userrole"].toString()="admin" { SetValidateRequest(false); // Sample Function to set validation } else { SetValidateRequest(true); // Sample Function to set validation } }  

infopath 2003 user role error

hi, i'm trying to create a user role for my form in infopath 2003. but when i add a user and click on the icon next to the texbox it gives me this error: The program cannot open the required dialog box beacause no locoation can be found

user mapping to a database and role membership to that database

When assigning a 'user mapped Login' to a database and role membership to that database, is it redundent to check/enable db_datareader, db_datawriter as well as db_owner or will check/enable db_owner become all that is necessary to provide role membership to the database?

httpcontext.current.user.identity.isauthenticated always false

Dear, please help me, I create two pages, the first one is the login page with user name and password textboxes - (not asp login control) , when clicking login button I check the login authentication, if it is true redirect to default page. in the default page if !IsCallBack then i check httpcontext.current.user.identity.isauthenticated if it is false i redirect the user to the login page. but my problem is that the httpcontext.current.user.identity.isauthenticated is always false. Below the section of authentication in web config < <authentication mode="Forms">forms loginUrl ="FrmUserLogin.aspx"  protection ="All"  timeout ="1"  name ="LoginRedirectCallback"  path ="/LoginRedirectCallback"  requireSSL ="false"  slidingExpiration ="true"  defaultUrl ="FrmDBLoginConfigaspx.aspx"  cookieless ="UseDeviceProfile"   < < </   </ </enableCrossAppRedirects ="false">credentials passwordFormat="Clear">user name ="admin" password ="admin"/>credentials>forms>authentication> thank you for any help.   Best Regards,

user role on sharepoint custom list

hi, can i set up a user role for a custom list form in sharepoint services 3 i want to use the "submit new absence" form. but i need to modify the form in a way that when a user open the form it fills the user his name or login name in the fields. and that the approver or "assigned to field" also is filled with the approvers name. i think i need to use a query for that, but how can i apply it to the fields of the absence list form

Changing a users role with RadioButtons (User is always in single role)

So I have a set of 5 radio buttons corresponding to the roles a user can have on my website.  I have been successfully able to retreive what radio button needs to be checked for the role the user is currently in... string username = Request.QueryString["username"]; // Get Access Levels and populate radio buttons. if (Roles.IsUserInRole(username, "Banned") == true) { RadioButton4.Checked = true; } if (Roles.IsUserInRole(username, "Member") == true) { RadioButton1.Checked = true; } if (Roles.IsUserInRole(username, "FOB_Employee") == true) { RadioButton2.Checked = true; } if (Roles.IsUserInRole(username, "FOB_Administrator") == true) { RadioButton3.Checked = true; } if (Roles.IsUserInRole(username, "Webmaster") == true) { RadioButton5.Checked = true; } My problem is I do not know what to do with the actual procedure of changing the roles based on the new radio button selection.  I have tried many different methods, including using if statements to check if the user is currently in the role, remove him/her from that roll, and then add the user to the newly selected role.  It appears, from my testing, that you can not

How to add colleagues to a user profile without admin priviliges programatically ...

Hi,I am working on a kind of a social networking site and the use case is as follows.1. User A sends a friendship request to User B.2. User B accepts.3. User A is added as a colleague in User B's Profile.4. User B is added as a colleague in User A's Profile.Step 2-4 are done using User B's login. Step 2 and 3 go fine but in step 4 I get the following error "This operation requires you to be managing your own data or have administrator privileges.". The API being used is UserProfile.Colleagues.Create (...);What is required is obvious but not possible in this scenario. SPSecurity.RunWithElevatedPrivileges does not help.  Any other way of accomplishing this.Thanks.

CreateUserWizard creating dupicate user while assigning Role.

protected void CreateUserWizard1_CreatedUser(object sender,  EventArgs e){Roles.AddUserToRole((sender as CreateUserWizard).UserName, "Customers");} CreateUserWizard is creating dupicate user while assigning Role.How can we assign Role without duplicating user record? I've observed ApplicationID for assigning Role is Differenent than Creating New User, so when ever Role assigning comes in, it creates  same user again with new UserID. Is it related to Web.Config in some way? As when I try to create user from "VisualStudio/Website/ASP.net Configuration" even then two users with same usernames are entered in aspnet_users with Different ApplicationID and UserID. One user has Role and another duplicate user is without Role status of IsApproved=1.Please help me to resolve this issue.Thanks!  

GoDaddy.Com is a negligent parent, so can somebody help this newbie set up admin/user logins?


I'm becoming increasing frustrated with the lack of support at GoDaddy.Com.  Today they're not even answering their phones!

All I'm trying to do is set up an admin and several user accounts on my site so I and several users can log on. I'm not even trying to do it remotely, but on their SQL server.

1. Using Query Analyzer I created a few users:

INSERT INTO aspnet_Users(ApplicationID,  UserName, LoweredUserName,  LastActivityDate).... That worked.

2. Next, I created a couple of roles:

INSERT INTO aspnet_Roles(ApplicationID, RoleName, LoweredRoleName).... That worked.

3. I then put the users in these roles:

INSERT INTO aspnet_UsersInRoles(UserID, RoleID)....  That, too, worked.

4. But then I tried to put those users, roles, and UsersInRoles into aspnet_Membership according to their own documentation--Activating ASP.NET 2.0 Personal Web Site User Account  http://help.godaddy.com/topic/216/article/885 using  UPDATE aspnet_Membership SET IsApproved = 1 WHERE UserId = 'MyUserId'

Nothing.  Although Query Analyzer tells me the command executed successfully, the aspnet_Membership table shows no entries.

It's my understanding that getting entries into this table is critical for the login procedure. So can somebod

Issue trying to remove user from role that is no longer available.


Using tutorials and some examples of handling membership permission on our site, i have a page that was built using examples found in those pages.. Anyway, now that it is all setup and working ran into first issue.. If a role is setup with a space in the name like this ("Read Only") then you get an error when you try to add someone to that role. But if i change it to be ("ReadOnly") it works fine and no issues..


                        <asp:GridView ID="GridViewRole" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSourceRoleObject"
                            DataKeyNames="RoleName" CellPadding="3" CellSpacing="3" AllowPaging="True">
                                <asp:CommandField ShowDeleteButton="True" DeleteText="Delete Role" />
                                        <asp:Button ID="Button1" runat="server" CausesValidation="false" Width="500px" OnClick="ToggleInRole_Click"
                                            Text='<%# ShowInRoleStatus( (string

Can Admin see a user's "Personalize this Page"?


Follow up question:

A Contribute user made some "Personalize this Page" changs only he can see. How can I, as an admin, see what this user has done without logging in with his acct?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend