473,320 Members | 1,711 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,320 software developers and data experts.

windows account query question

Hello,

It should be very simple, but I just can not find out how to do it.

I am developing an info share application. The requirement is that everyone
can view the information, but can only change the information belong to him.
We need to use windows domain account to do the authentication.
Can anyone tell me how to do domain account authentication in c#? Is there a
class to do it?

Many Thanks

Jerry

--
hello, please help
Nov 16 '05 #1
1 1653
Jerry,

For something like this, I would a ServicedComponent. You can derive a
class from ServicedComponent, and then assign roles to each method on the
class, allowing only certain members of each role to make the call.

To do this, you would start by placing the following attributes on your
assembly:

// Indicate that this should run out of process.
[assembly: ApplicationActivation(ActivationOption.Server)]
// Specify that the types in this assembly (that derive from
ServicedComponent) require access control.
[assembly:ApplicationAccessControl(true,
AccessChecksLevel=AccessChecksLevelOption.Applicat ionComponent,
Authentication=AuthenticationOption.Privacy,
ImpersonationLevel=ImpersonationLevel.Identify)]

The first attribute, ApplicationActivation, indicates that the
components in the application (your ServicedComponents) will run out of
process. This is needed if you are going to authenticate calls on the
class/interface/method level.

The ApplicationAccessControl attribute indicates how access to the types
in the application are handled. true means that you have to authenticate
calls. AccessChecksLevel indicates whether you want to authenticate on the
process level, or for every call. The value of ApplicationComponent means
that every call will be authenticated. ImpersonationLevel indicates what
identity the application should run under. With
ImpersonationLevel.Identify, it will be able to identify (and authenticate)
the caller, but the process will run under the user account that you
specify. Authentication is how you want to protect the messages as they
travel between client and server. The Privacy value is the highest level,
making sure that the contents were encrypted, and not modified.

Then, on the component level, you will have to define the interface for
the component that you want to limit calls on. For each method of the
interface, you would attach the following attribute:

public interface IInterface
{
[SecurityRole("AllowedDoSomethingCallers")]
void DoSomething();
}

Then, you implement this on your class. When the class is registered
with COM+, you will see that there is a role specified in the roles for the
application called AllowedDoSomethingCallers. To this, you can easily add
and remove users and groups (although you should always add groups, and you
can do this through the UI or programatically) to the role. Then, when
someone from outside of that role tries to make a call, an exception is
thrown, denying the call.

For more information, check out the section of the .NET framework
documentation titled "Writing Serviced Components", located at (watch for
line wrap):

http://msdn.microsoft.com/library/de...Components.asp

Most of the information you will need is located there. It's a lot to
take in, and it seems convoluted, but in reality, it handles most of the low
level plumbing for this and other kinds of tasks (like object pooling,
activation, transaction management, among other things), and saves a
tremendous amount of time once you become accustomed to it.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"jerry.xuddd" <je********@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
Hello,

It should be very simple, but I just can not find out how to do it.

I am developing an info share application. The requirement is that
everyone
can view the information, but can only change the information belong to
him.
We need to use windows domain account to do the authentication.
Can anyone tell me how to do domain account authentication in c#? Is there
a
class to do it?

Many Thanks

Jerry

--
hello, please help

Nov 16 '05 #2

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

Similar topics

11
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows...
0
by: Gary | last post by:
All, I am experiencing an error using MSDTC with SQL Server 2000 on Windows 2003 server. The code in question is a stored procedure that does a query within a transaction using linked servers....
2
by: Vaap | last post by:
I did lot of googling to see if I can solve the SQL server not found problem while trying to run ASP.Net community starter kit from an XP machine to Windows 2003 server hosting SQL server 2000...
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...
0
by: CESAR DE LA TORRE [MVP] | last post by:
I am using WSE 3.0 with Visual Studio 2005, specifically I'm using Kerberos authentication and passing Kerberos ticket from Presentation Tier (VSTO.2005 client) to Server Tier through our Web...
7
by: Alice Wong | last post by:
I am setting up my Web ASP.net application to connect to Sql server using windows authentication. I set up IIS to have integrated windows authenication and sql to allow Windows authentication....
3
by: Lucky | last post by:
Hi guys, after long long time. i'm back again with another problem. this time i think the problem is very very interesting and i really need you help on this. i'm trying to connect to the...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
3
by: Matt Lowrance | last post by:
I'm hoping someone can give me a little guidance. I have written a simple Windows Service that goes out and scrapes a few web pages and updates some data in an access database. The service works...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

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.