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.GetCurre nt.Name.Spilt("/")(1)
End Function
--------------------
After launching the site, the following error occurs:
--------------------
[COMException (0x80004005): Unspecified error
]
System.DirectoryServices.Interop.IAdsContainer.Get Object(String
className, String relativeName) +0
System.DirectoryServices.DirectoryEntries.Find(Str ing 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?
--
Message posted via http://www.dotnetmonster.comThe 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.
"Shihao Png via DotNetMonster.com" <forum@.DotNetMonster.com> wrote in
message news:2aeb59d02bc64258b8b6e15300e5aaa4@.DotNetMonste r.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.GetCurre nt.Name.Spilt("/")(1)
> End Function
> --------------------
> After launching the site, the following error occurs:
> --------------------
> [COMException (0x80004005): Unspecified error
> ]
> System.DirectoryServices.Interop.IAdsContainer.Get Object(String
> className, String relativeName) +0
> System.DirectoryServices.DirectoryEntries.Find(Str ing 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?
> --
> Message posted via http://www.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?
--
Message posted via http://www.dotnetmonster.com
0 comments:
Post a Comment