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

how to have component run in security context of windows user?

I have an application/component that updates an individual's active directory information. The current application finds the active directory entry via the following..

Dim entry As DirectoryEntry = New DirectoryEntry("LDAP://" & m_DomainName, m_Username, m_Password, AuthenticationTypes.FastBind
Dim ds As New DirectorySearcher(entry
Dim filter As String = "(sAMAccountName=" & "joeuser" & ")
ds.Filter = filte
Dim results As SearchResultCollectio
Dim searchResults As SearchResul
searchResults = ds.FindOn
Dim user As DirectoryEntry = searchResults.GetDirectoryEntry(
user.Properties("description").Value = "Goat Farmer
user.CommitChanges(

The problem..
Only the employee has rights to update their AD information. How can I create the "entry" with the correct permissions of the user running the web application? This is a web application and I currently use forms authentication on the existing web application

Any help would be very much appreciated
dave
Jul 21 '05 #1
2 3417
Hello Dave,

Thanks for your post. As I understand, you want to impersonate a user in
your ASP .NET Web application in order to updates an individual's active
directory information. Please correct me if there is any misunderstanding.
Based on my experience and research, you will need to perform the following
steps:

1. Make sure that the ASP .NET Process Identity is set to System. The
Machine.config file looks like below:
<system.web>
<processModel enable="true"
userName="System"
password="AutoGenerate"/>
</system.web>

The following MSDN article describes ASP.NET Process Identity in detail:
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconConfiguringASPNETProcessIdentity.asp

2. Go to "Control Panel" -> "Administrative Tools" -> "Internet Information
Services Manager", choose the corresponding Web Site, open its Properties
page, choose "Directory Security", uncheck "Enable anonymous access" in
"Authentication and access control".

3. Impersonate the authenticating user in your code:

Dim impersonationContext As
System.Security.Principal.WindowsImpersonationCont ext
Dim currentWindowsIdentity As System.Security.Principal.WindowsIdentity

currentWindowsIdentity = CType(User.Identity,
System.Security.Principal.WindowsIdentity)
impersonationContext = currentWindowsIdentity.Impersonate()

'Insert your code that runs under the security context of the
authenticating user here.

impersonationContext.Undo()

Please refer to the following KB article for detailed information:

INFO: Implementing Impersonation in an ASP.NET Application
http://support.microsoft.com/?ID=306158

Please check it on your side, and let me know the result.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #2
Hello Dave,

Thanks for your post. As I understand, you want to impersonate a user in
your ASP .NET Web application in order to updates an individual's active
directory information. Please correct me if there is any misunderstanding.
Based on my experience and research, you will need to perform the following
steps:

1. Make sure that the ASP .NET Process Identity is set to System. The
Machine.config file looks like below:
<system.web>
<processModel enable="true"
userName="System"
password="AutoGenerate"/>
</system.web>

The following MSDN article describes ASP.NET Process Identity in detail:
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconConfiguringASPNETProcessIdentity.asp

2. Go to "Control Panel" -> "Administrative Tools" -> "Internet Information
Services Manager", choose the corresponding Web Site, open its Properties
page, choose "Directory Security", uncheck "Enable anonymous access" in
"Authentication and access control".

3. Impersonate the authenticating user in your code:

Dim impersonationContext As
System.Security.Principal.WindowsImpersonationCont ext
Dim currentWindowsIdentity As System.Security.Principal.WindowsIdentity

currentWindowsIdentity = CType(User.Identity,
System.Security.Principal.WindowsIdentity)
impersonationContext = currentWindowsIdentity.Impersonate()

'Insert your code that runs under the security context of the
authenticating user here.

impersonationContext.Undo()

Please refer to the following KB article for detailed information:

INFO: Implementing Impersonation in an ASP.NET Application
http://support.microsoft.com/?ID=306158

Please check it on your side, and let me know the result.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #3

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

Similar topics

1
by: dave | last post by:
I have an application/component that updates an individual's active directory information. The current application finds the active directory entry via the following.. Dim entry As DirectoryEntry...
0
by: Jiho Han | last post by:
This seems like a often-asked topic. I created a windows service and installed it on my workstation. The application basically goes out and "receieves" messages from a queue on a remote server....
87
by: Sony Music CDs install Malware | last post by:
Whether you are a web surfer or a C++ developer, if you use Windows be cautioned about SONY music CDs. They contain 'viewer' type software that is actually a trojan horse for a "rootkit". The...
5
by: John Lee | last post by:
Hi, I have a component with some static public methods and is it possible from inside my method to decide if my component is invoked by an ASP.NET application (such as web service) or a windows...
0
by: Jon Pope | last post by:
Occasionally, I see the following error whenever I close a form which is being displayed with the ShowDialog() method within my C# app: Error message: External component has thrown an exception....
9
by: Stan | last post by:
Here is my scenario: Web server ------------ Framework 1.1 Application proxy for the serviced component Component server ------------------- Framework 1.0
2
by: KaNos | last post by:
Hello world, I've made a webservice (c# v2) to install in a server IIS 6 on a Windows 2000 last SP. We can use the webservice in local, throw the pages wich present the methods, with a windows...
1
by: novicedlh | last post by:
Hello, I am creating a webservice that collects user information and stores it in a database. Since the user information contains sensitive data like SSN I am planning to use WS-Security (WSE...
4
by: Kerem Gümrükcü | last post by:
Hi, the topic of this thread implies the question. Why does this happen. What can i do against it. App runs in admin context, then ii switch to user standard user context and open a form with...
3
by: RedHair | last post by:
I use the Form Authentication and Role base security to secure one ASP.NET 3.5 appication. Below are security settings in web.config <location path="testAdmin.aspx"> <system.web>...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.