The dread COMException (0x80004005): Unspecified error...

  • Thread starter Shihao Png via DotNetMonster.com
  • Start date
S

Shihao Png via DotNetMonster.com

Well, the problem I'am having now applies to web applications only.
Therefore, I believe it has something to do with security settings. Here's
the code:

-------------------------------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim child As System.DirectoryServices.DirectoryEntry

' dirEntry is a DirectoryEntry component that points to
' WinNT://someserver
' I tried to retrieve the current user Active Directory information by
' using the Find function and specifying the logon userId and which
' schema the user belongs to. In this case, "User"...

child = dirEntry.Children.Find(getCurrentUserId, "User")

' lb is a ListBox

lb.DataSource = child.Properties()
End Sub

Public Function getCurrentUserId() As String

' I attempt to retrieve the current user windows logon id with the
' domain name removed using a Spilt("/") but it returns an empty
' string instead

Return
System.Security.Principal.WindowsIdentity.GetCurrent.Name.Spilt("/")(1)
End Function
-------------------------------------------------------------------

After launching the site, the following error occurs:

-------------------------------------------------------------------
[COMException (0x80004005): Unspecified error
]
System.DirectoryServices.Interop.IAdsContainer.GetObject(String
className, String relativeName) +0
System.DirectoryServices.DirectoryEntries.Find(String name, String
schemaClassName)
ADSearch.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\
wwwroot\ADSearch\WebForm1.aspx.vb:36
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
-------------------------------------------------------------------

I've tried using only the windows logon userId(dirEntry.Children.Find
(getCurrentUserId)) to retrieve the Active Directory entry for the current
user but the error still comes back.

I'am at my wits end...
solutions anyone?
 
O

Oleg Ogurok

The user under which your application is running (most likely
IUSR_SERVERNAME) might not have permissions to access AD.
You should configure the virtual directory's security to run under a user
that has permissions to do so. Simply create a separate account for it in AD
and use it as the anonymous user (in IIS properties).
Alternatively, you can use ASP.NET impersonation configurable in web.config
(search MSDN for it).

Try doing the same AD stuff from a winforms application, and see if it's
indeed the problem with permissions.

-Oleg.
 
S

Shihao Png via DotNetMonster.com

Sorry but I don't really get what you mean...do you mean that the user
account that I run on when I attempt to search AD do not have the
permission to do so by the AD server? So that means I should configure AD
so that it allows searching by my user account? Is that what you mean?
 

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,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top