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

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.InteropServices.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 "DirectoryEntry
child"
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (!IsPostBack)
{
DirectoryEntry user_entry = new
DirectoryEntry("LDAP://DOMAIN.org/DC=DOMAIN,DC=org");
DirectorySearcher mySearcher = new DirectorySearcher(user_entry);
Session["User.ID"] = User.Identity.Name.ToString().Substring(12);
mySearcher.Filter = ("(CN=" + Session["User.ID"].ToString() + ")");
SearchResult resEnt = mySearcher.FindOne();

Session["User.Name"] =
resEnt.GetDirectoryEntry().Properties["DisplayName"].Value.ToString();
Session["User.Path"] = resEnt.Path.ToString();
Session["User.CN"] =
resEnt.GetDirectoryEntry().Properties["CN"].Value.ToString();
lblWelcome.Text = "Welcome, " + Session["User.Name"].ToString();

string TempString = resEnt.Path.ToString().Replace("CN=" +
Session["User.CN"].ToString() + ",", "");
DirectoryEntry local_entry = new DirectoryEntry(TempString);
//this is where the error occurs
foreach(DirectoryEntry child in local_entry.Children)
{
if (child.Properties.Contains("Mail") == true)
{
string tempString1 = child.Properties["DisplayName"].Value.ToString();
string tempString2 = child.Properties["Mail"].Value.ToString();
ListItem tempItem = new ListItem(tempString1,tempString2);
ddlNominee.Items.Add(tempItem);
}
}
}
}
Nov 16 '05 #1
0 1281

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

Similar topics

1
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...
9
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...
6
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.