DirectoryEntry error.... "Type expected."http://forums.asp.net/t/383835.aspx/1?DirectoryEntry+error+Type+expected+Tue, 04 Nov 2003 17:14:50 -0500383835383835http://forums.asp.net/p/383835/383835.aspx/1?DirectoryEntry+error+Type+expected+DirectoryEntry error.... "Type expected." I am getting a compilation error with the following code : <pre class="prettyprint">&lt;script runat=&quot;server&quot;&gt; Public Class ActiveDirectory Public Function GetUserInfo(ByVal inSAM as String, ByVal inType as String) as String Try Dim sPath as String = &quot;LDAP://myDomain.com/DC=mydomain,DC=com&quot; Dim SamAccount as String = Right(inSam, Len(inSam) - InStr(inSam, &quot;\&quot;)) Dim myDirectory as = New DirectoryEntry(sPath, &quot;EnterPrise Admin&quot;, &quot;Password&quot;) Dim mySearcher as New DirectorySearcher(myDirectory) Dim mySearchResultColl as SearchResultCollection Dim mySearchResult as SearchResult Dim myResultPropColl as ResultPropertyCollection Dim myResultPropValueColl as ResultPropertyValueCollection 'Build LDAP query mySearcher.Filter = (&quot;(&amp;(objectClass=user)(samaccountname=&quot; &amp; SamAccount &amp;&quot;))&quot;) mySearchResultColl = mySearcher.Findall() 'We only expect one user from the search Select Case mySearchResultColl.Count Case 0 Return &quot;Null&quot; Exit Function Case is &gt; 1 Return &quot;Null&quot; Exit Function end select ' Get the search result from the collection mySearchResult = mySearchResultColl.Item(0) ' Get the properties, they contain the usefull info myResultPropColl = mySearchResult.Properties ' Return the requested property.. displayname, mail, etc myResultPropValueColl = myResultPropColl.Item(inType) Return CStr(myResultPropValueColl.Item(0)) Catch ex as System.Exception ' Handle errors End try end function Dim sEmail as String = GetUserInfo(User.Identity.Name, &quot;mail&quot;) end class</pre> The Error is Type Expected and its on the following line of code : <pre class="prettyprint"> Dim myDirectory as = New DirectoryEntry(sPath, "EnterPrise Admin", "Password") </pre> Any ideas ? 2003-11-03T19:59:17-05:00383986http://forums.asp.net/p/383835/383986.aspx/1?Re+DirectoryEntry+error+Type+expected+Re: DirectoryEntry error.... "Type expected." You need to declare the type of object you are instantiating:<pre class="prettyprint">Dim myDirectory as <b>DirectoryEntry</b> = New DirectoryEntry(sPath, &quot;EnterPrise Admin&quot;, &quot;Password&quot;)</pre> 2003-11-03T22:31:11-05:00384696http://forums.asp.net/p/383835/384696.aspx/1?Re+DirectoryEntry+error+Type+expected+Re: DirectoryEntry error.... "Type expected." I found out that the problem was actually to do with me not being able to import System.DirectoryServices I had to copy the .dll file to a bin folder in my applications folder 2003-11-04T16:15:30-05:00384772http://forums.asp.net/p/383835/384772.aspx/1?Re+DirectoryEntry+error+Type+expected+Re: DirectoryEntry error.... "Type expected." That is also an issue, but with any strongly typed language, you will need to declare the type as well. 2003-11-04T17:14:50-05:00