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!
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!