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