import dll issue

R

richb330

Hi,

I have got hold of a script from the ms web site that adds an entry into the
active directory. I have copied the script into VB(.net 2003) and made the
reference to the system.directoryservices dll but all of the references
within the script that state 'DirectoryEntry' all state 'Type 'Directory
Entry' is not defined'. I think i've imported the dll correctly through
solution explorer and I can see the System.DirectoryServices within the
References section. do i need to make reference to the dll within the vb
program statements?

This is the script:

Try

' Bind to the Users container, add a new group and a new contact.
Dim de As New DirectoryEntry("LDAP://CN=temp,DC=mdlmarinas,DC=co,DC=uk")
Dim newGroup As DirectoryEntry = de.Children.Add("CN=Temp", "user")
newGroup.CommitChanges()
Dim newContact As DirectoryEntry = de.Children.Add("CN=New Contact",
"contact")
newContact.CommitChanges()
' Bind to the Computers container and add a new computer.
Dim de01 As New DirectoryEntry("LDAP://CN=Computers,DC=fabrikam,DC=com")
Dim newComputer As DirectoryEntry = de01.Children.Add("CN=New Computer",
"computer")
newComputer.CommitChanges()
Catch Exception1 As Exception
' If a COMException is thrown, then the following code can catch the text of
the error.
' For more information about handling COM exceptions, see Handling Errors.
Dim COMEx As System.Runtime.InteropServices.COMException = CType(Exception1,
System.Runtime.InteropServices.COMException)
Console.WriteLine(COMEx.ErrorCode)

End Try
 
L

Lon

You need to have the following code before the Module "modulename" line:

Imports System.DirectoryServices
 
R

richb330

Many thanks for the reply. Could you clarify where the Imports.. line
goes?
I'm getting confused when you talk about the 'Module' line.

thanks.
 
L

Lon

The very first line should be the imports line
like this:

Imports System.ServiceProcess
Imports System.IO
Imports System.Diagnostics
Imports ICSharpCode.SharpZipLib.Zip
Imports System.Web.Mail

Public Class Module1
Inherits System.ServiceProcess.ServiceBase

your code goes here

End Class
 
R

richb330

ah, many thanks.

got it now.


Lon said:
The very first line should be the imports line
like this:

Imports System.ServiceProcess
Imports System.IO
Imports System.Diagnostics
Imports ICSharpCode.SharpZipLib.Zip
Imports System.Web.Mail

Public Class Module1
Inherits System.ServiceProcess.ServiceBase

your code goes here

End Class
 

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

Top