0

i have created a role in asp.net as :

<configuration>

  <CustomUsersSection>

    <Roles>

      <add RoleName="Administrator"/>
    </Roles>

<Users>


      <add UserName="admin" Password="password" 
           Email="abot@home" Role="Administrator"/>
    </Users>
</CustomUsersSection>

</configuration>

Now i want to add all the Admin that are added into a table from a sql-server to the role define above. Thanks for any assistance.

My Admin table structure is as follows:
AdminId
AdminName
EmailAddress
...
Abhishek gupta
  • 463
  • 3
  • 12
  • 33
  • 1
    Are you using ASP.NET membership? Regardless, this is not enough information to effectively answer your question. Any answer would have to make MANY assumptions about your code and how it's structured. – Josh Darnell Feb 25 '13 at 20:39
  • sir,as we are adding user to a role administrator in the above code. i want to add all the admin save into my table dynamically to administrator role. so that whenever any new admin get added into my table. it automatically assign to Admin role. – Abhishek gupta Feb 26 '13 at 13:05

1 Answers1

0

Assuming you're using ASP.NET membership, I would look into implementing your own membership provider. You can do it relatively easily and there is a lot of material on the Web about how to do that. You will then be able to implement your own test (such as whether a record exists in a database table) to determine whether a user is in the Admin role.

I suggest, though, that you learn about the built-in Membership Providers and the membership database ASP.NET automatically creates before you do this. This is because that's a pretty decent implementation and does things that would be labor-intensive to do for yourself, such as encrypting the information being stored to protect it from being easily hacked.

Ann L.
  • 13,760
  • 5
  • 35
  • 66
  • Maam, i tried implementing though ASP.NET membership but user i create doesn't get inserted into aspnet_Users table. As it show the number of user created is 2 but the table is empty and no webconfig code get updated. what could be the error. As i am doing through website in solution explorer it works but not from the webApplication in solution explorer. – Abhishek gupta Feb 27 '13 at 07:06
  • Is there any a way to add user and then adding that user after the website being deployed to live site?? – Abhishek gupta Feb 27 '13 at 08:07
  • If it says the number of users created is 2 but your copy of the database doesn't show the users, the most likely cause is that it's pointing to a different database than the one you're looking at. ASP.NET Membership will create a database if it can't find one, so it may have created a new one and put the new users in that. The connection string in the web.config should tell you where the membership provider is looking for the database. – Ann L. Feb 27 '13 at 15:07