DirectoryServices error!

E

Enosh Chang

Hi all,

I encounter some problem in DirectoryServices, could someone help me?

private void InitLoginUser()
{
DirectoryEntry objEntry = new DirectoryEntry();
DirectorySearcher objSearcher = new DirectorySearcher();
SearchResult objResult;

try
{
objEntry.Path = "LDAP://dc=iec,dc=inventec";

objSearcher.SearchRoot = objEntry;
objSearcher.Filter = "(sAMAccountName=*464*)";
objSearcher.SearchScope = SearchScope.Subtree;
objSearcher.PropertiesToLoad.Add("displayName");
objResult = objSearcher.FindOne();
} // try
finally
{
} // finally
}

private void Page_Load(object sender, System.EventArgs e)
{
// ±N¨Ï¥ÎªÌµ{¦¡½X¸m©ó¦¹¥Hªì©l¤Æºô­¶
if (!IsPostBack)
InitLoginUser();
}

But it always show error message as following:

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: The
specified domain either does not exist or could not be contacted

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[COMException (0x8007054b): The specified domain either does not exist or
could not be contacted]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +514
System.DirectoryServices.DirectoryEntry.Bind() +10
System.DirectoryServices.DirectoryEntry.get_AdsObject() +10
System.DirectoryServices.DirectorySearcher.FindAll(Boolean
findMoreThanOne) +199
System.DirectoryServices.DirectorySearcher.FindOne() +31
MailTracking.WebForm1.InitLoginUser() in
c:\inetpub\wwwroot\mailtracking\default.aspx.cs:35
MailTracking.WebForm1.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\mailtracking\default.aspx.cs:46
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Page.ProcessRequestMain() +724


Anyway, thanks all!
 
N

Natty Gur

Hi,

you need to write the full domain name with DCs

For example if the domin name is microsoft.com it should be :

DC=microsoft,DC=com

Connect to computers in a domain. For example, "LDAP://CN=
computer-name, CN=Computers, DC= domain-controller1, DC=
domain-controller2,...".



Natty Gur, CTO
Dao2Com Ltd.
34th Elkalay st. Raanana
Israel , 43000
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top