473,654 Members | 3,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error during remote access to Active Directory

I'm trying to use Active Directory to get a list of users that are in the
same directory as the logon user. I'm trying to do this as a Web App written
in C# using Windows Security and Impersonation. When running from the local
host I have no problem; but when I try the same thing remotely I get the
error "System.Runtime .InteropService s.COMException" on the second hit on
Active Directory, the first hit works fine. I used to get the same error all
the time until I started using Impersonation.

Any suggestions as to what might be the issue?

Below is the specific code in question. It errors out at "DirectoryE ntry
child"
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
if (!IsPostBack)
{
DirectoryEntry user_entry = new
DirectoryEntry( "LDAP://DOMAIN.org/DC=DOMAIN,DC=or g");
DirectorySearch er mySearcher = new DirectorySearch er(user_entry);
Session["User.ID"] = User.Identity.N ame.ToString(). Substring(12);
mySearcher.Filt er = ("(CN=" + Session["User.ID"].ToString() + ")");
SearchResult resEnt = mySearcher.Find One();

Session["User.Name"] =
resEnt.GetDirec toryEntry().Pro perties["DisplayNam e"].Value.ToString ();
Session["User.Path"] = resEnt.Path.ToS tring();
Session["User.CN"] =
resEnt.GetDirec toryEntry().Pro perties["CN"].Value.ToString ();
lblWelcome.Text = "Welcome, " + Session["User.Name"].ToString();

string TempString = resEnt.Path.ToS tring().Replace ("CN=" +
Session["User.CN"].ToString() + ",", "");
DirectoryEntry local_entry = new DirectoryEntry( TempString);
//this is where the error occurs
foreach(Directo ryEntry child in local_entry.Chi ldren)
{
if (child.Properti es.Contains("Ma il") == true)
{
string tempString1 = child.Propertie s["DisplayNam e"].Value.ToString ();
string tempString2 = child.Propertie s["Mail"].Value.ToString ();
ListItem tempItem = new ListItem(tempSt ring1,tempStrin g2);
ddlNominee.Item s.Add(tempItem) ;
}
}
}
}
Nov 16 '05 #1
0 1293

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

Similar topics

1
5025
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I double-checked the path to my error log. It is in /var/www/logs/php_error_log Thanks. :) -Wayne Stevenson
9
3168
by: Patrick | last post by:
I have an ASP.NET page that searches for someone in the corporate Active Directory. It had been working fine until recently when I changed from Basic Authentication on IIS6 back to Integrated Windows authentication. The error occurs on the FindAll method. The exceptions are as follows. anyway of getting the code working with Integrated Windows authentication (too annoying for user to enter user-name/password). Note I do need to use...
6
4948
by: Chris Love | last post by:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) I get this the frist time I open an ASP.NEt 2.0 site on my development machine now. It started happening when I tried to use the...
1
6656
by: TerrenceJ | last post by:
Hi there I've configure our SBS 2003 server to allow remote access and Outlook over internet. The mail works fine, but when I try remote access, I am asked for username and password, which I complete and then I get this error. ____________________________________ Access to the path "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\remote\3f1585d2\3070828a" is denied. Description: An unhandled exception occurred...
0
8372
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8285
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8591
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7304
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5621
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4293
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2709
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1592
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.