473,404 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Using Windows Authentication in ASP.NET - Adding properties to users

Guys,

I'm unsure how to use windows authentication in an intranet application. I'd
like to user existing windows account to identify users however the issue I
have is how to then add settings to those users and map them to roles.

If I'd like to restrict the windows users which log on and what tasks they
can perform in the application how should I do this? Presumably I'd need one
user to log in initially and perform admin type tasks e.g. assign windows
users permissions to use the application, how should I do this? How do I
create the first user who can log in?

Best Regards

Matt
Feb 27 '07 #1
6 2346
On Feb 27, 9:32 am, "Matt Adamson" <Adamson_Matt...@hotmail.com>
wrote:
Guys,

I'm unsure how to use windows authentication in an intranet application. I'd
like to user existing windows account to identify users however the issue I
have is how to then add settings to those users and map them to roles.

If I'd like to restrict the windows users which log on and what tasks they
can perform in the application how should I do this? Presumably I'd need one
user to log in initially and perform admin type tasks e.g. assign windows
users permissions to use the application, how should I do this? How do I
create the first user who can log in?

Best Regards

Matt
It depends on where do you want to have the user roles.

If you want to have the roles in the intranet application

Set the authentication mode to "Windows" and use the
User.Identity.Name property to identify your user. In the application
make a database with users/roles and query that database to set the
roles. For example it can be done in the global.asax within the
AuthenticateRequest

Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As
EventArgs)

If Request.IsAuthenticated = True Then

Dim roles() As String

..... code to assign roles() here........

Context.User = New GenericPrincipal(Context.User.Identity, roles)

End If

End Sub

After that you will be able to find if the user has rights or not
using if User.IsInRole("marketing_admin") then....

Something like this.

Feb 27 '07 #2
Thanks Alexey

However how would I use the existing user store from the membership API i.e.
there are user tables

1) aspnet_Membership
2) aspnet_Users

Should I create a new User table which contains the windows log in name e.g.
MICROSOFT\BGATES and then use a record in the member ship tables for other
data such as full name / email address e.t.c.?

Let me know your thoughts as I haven't seen any good examples showing a user
system set up with windows authentication

Best Regards

Matt

"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@8g2000cwh.googlegrou ps.com...
On Feb 27, 9:32 am, "Matt Adamson" <Adamson_Matt...@hotmail.com>
wrote:
>Guys,

I'm unsure how to use windows authentication in an intranet application.
I'd
like to user existing windows account to identify users however the issue
I
have is how to then add settings to those users and map them to roles.

If I'd like to restrict the windows users which log on and what tasks
they
can perform in the application how should I do this? Presumably I'd need
one
user to log in initially and perform admin type tasks e.g. assign windows
users permissions to use the application, how should I do this? How do I
create the first user who can log in?

Best Regards

Matt

It depends on where do you want to have the user roles.

If you want to have the roles in the intranet application

Set the authentication mode to "Windows" and use the
User.Identity.Name property to identify your user. In the application
make a database with users/roles and query that database to set the
roles. For example it can be done in the global.asax within the
AuthenticateRequest

Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As
EventArgs)

If Request.IsAuthenticated = True Then

Dim roles() As String

.... code to assign roles() here........

Context.User = New GenericPrincipal(Context.User.Identity, roles)

End If

End Sub

After that you will be able to find if the user has rights or not
using if User.IsInRole("marketing_admin") then....

Something like this.

Feb 27 '07 #3
On Feb 27, 2:08 pm, "Matt Adamson" <Adamson_Matt...@hotmail.com>
wrote:
Thanks Alexey

However how would I use the existing user store from the membership API i.e.
there are user tables

1) aspnet_Membership
2) aspnet_Users
No, I suggested to use "Windows authentication", not a "Form
authentication".

Should I create a new User table which contains the windows log in name e.g.
MICROSOFT\BGATES and then use a record in the member ship tables for other
data such as full name / email address e.t.c.?
Yes, my idea was to use such tables like AspNetAccessProvider does,
where you can assign MICROSOFT\BGATES to his roles. At the same time,
all information like full name / email address and so on is available
in Active Directory (AD) and this can be a second approach you have to
think of. I said nothing about it in the first post because this way
could be more complex to implement. In this case you can call the
information about group membership, and user profile directly from AD.
How to do that - please google for "ASP.NET Active Directory" - I'm
sure you can find many simple examples you can test. In my experience,
it is better to work with AD through a custom COM+ (can be developed
e.g. in VB6) because of the security reasons. All AD-related functions
could be included in this COM+ and used from ASP.NET. I can give you
more details later on if you'll decide to go this way...

Feb 27 '07 #4
I'm confused as AspNetAccessProvider is for microsoft Access.

I don't actually want to extract any information from active directory I
just wanted to use the windows log in name and associate this with user
details held within the application. I presume I could have done this using
a combination of the records in aspnet_Membership aspnet_Users with another
user table.

"Alexey Smirnov" <al************@gmail.comwrote in message
news:11*********************@h3g2000cwc.googlegrou ps.com...
On Feb 27, 2:08 pm, "Matt Adamson" <Adamson_Matt...@hotmail.com>
wrote:
>Thanks Alexey

However how would I use the existing user store from the membership API
i.e.
there are user tables

1) aspnet_Membership
2) aspnet_Users

No, I suggested to use "Windows authentication", not a "Form
authentication".

>Should I create a new User table which contains the windows log in name
e.g.
MICROSOFT\BGATES and then use a record in the member ship tables for
other
data such as full name / email address e.t.c.?

Yes, my idea was to use such tables like AspNetAccessProvider does,
where you can assign MICROSOFT\BGATES to his roles. At the same time,
all information like full name / email address and so on is available
in Active Directory (AD) and this can be a second approach you have to
think of. I said nothing about it in the first post because this way
could be more complex to implement. In this case you can call the
information about group membership, and user profile directly from AD.
How to do that - please google for "ASP.NET Active Directory" - I'm
sure you can find many simple examples you can test. In my experience,
it is better to work with AD through a custom COM+ (can be developed
e.g. in VB6) because of the security reasons. All AD-related functions
could be included in this COM+ and used from ASP.NET. I can give you
more details later on if you'll decide to go this way...

Feb 27 '07 #5
On Feb 27, 5:40 pm, "Matt Adamson" <Adamson_Matt...@hotmail.com>
wrote:
I'm confused as AspNetAccessProvider is for microsoft Access.
take a look here

http://weblogs.asp.net/scottgu/pages...QL-Server.aspx

Feb 27 '07 #6
Thanks, how would you give the first ever user though who could be an
adminstrator and log in to assign new roles to existing windows users. This
bit is unclear to me.

"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@a75g2000cwd.googlegr oups.com...
On Feb 27, 5:40 pm, "Matt Adamson" <Adamson_Matt...@hotmail.com>
wrote:
>I'm confused as AspNetAccessProvider is for microsoft Access.

take a look here

http://weblogs.asp.net/scottgu/pages...QL-Server.aspx

Feb 28 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my web.config file in the root with Forms...
4
by: chris.dunigan | last post by:
I'm looking for an example of how to execute an existing DTS­ package from an ASP (VB)script and would appreciate any and all response. ­I don't even know if it's possible Thanks - Chuck...
9
by: Ben Dewey | last post by:
Project: ---------------------------- I am creating a HTTPS File Transfer App using ASP.NET and C#. I am utilizing ActiveDirectory and windows security to manage the permissions. Why reinvent...
2
by: YRao | last post by:
I am going to create intranet application using Windows Authentication using C# asp.net I am having following problem: 1 setting windows Authentication, it will validate for all users, user...
4
by: Kristof Despiere | last post by:
Suppose you have one domain, filled with a couple of users. What needs to be done now is I need to start a windows application from a webform by pressing a button on the webform (for example). ...
3
by: Fredrik Elestedt | last post by:
Hi, I've been trying to use FormsAuthentication agains windows users and groups - not Active Directory. I couldn't find any articles on this directly, not to say that there aren't any out...
4
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
14
by: tshad | last post by:
I am trying to set up an intranet at work that will use our Active directory to authorize our users. We also want them to access the site from the outside (such as at home) and also be...
2
by: Arielle | last post by:
Foreword: Our Sharepoint site runs off both Forms Based and Windows Authentication. That being said some users have dual accounts for both methods of authentication...but not all users. Each...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.