I have some problem with some VB.Net development using
system.directoryservices and I was hoping that someone could help me out.
The details are as follows:
I have t his snippet of code:
Dim UserSearcher As DirectorySearcher
Dim UserResult As SearchResult
Dim Userentry As DirectoryEntry
UserSearcher = New DirectorySearcher(LDAP://DC=LOCALDOMAIN)
UserResult = UserSearcher.FindOne()
If Not UserResult Is Nothing Then
UserEntry = UserResult.GetDirectoryEntry
UserEntry.UsePropertyCache = True
TextBox1.Text = Userentry.Properties("userPrincipalName").Value
returns its userPrincipalName.
Code is run in a local windows application. User is logged onto the PC using
a Domain Admin account. The value returned is as expected.
Code is run inside an asp.net page (IIS 5). Authentication is set to
Integrated only (Anonymous disabled). Web.config set to:
<authentication mode="Windows" />
User is logged into the aspx page using a Domain Admin account. The page
returns the following error:
The Active Directory datatype cannot be converted to/from a native DS
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 Active
Directory datatype cannot be converted to/from a native DS datatype
The web server is a member server (Windows 2000 Server SP1) of the
LOCALDOMAIN (AD) domain.
The same error happens for "samAccountName" property but I can get other
properties like "cn" and "accountExpires".