By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,256 Members | 1,272 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,256 IT Pros & Developers. It's quick & easy.

import dll issue

P: n/a
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

Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Lon
You need to have the following code before the Module "modulename" line:

Imports System.DirectoryServices

"richb330" <ri******@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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

Nov 21 '05 #2

P: n/a
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.

"Lon" <lo*@apcare.net> wrote in message
news:OQ**************@TK2MSFTNGP14.phx.gbl...
You need to have the following code before the Module "modulename" line:

Imports System.DirectoryServices

"richb330" <ri******@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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


Nov 21 '05 #3

P: n/a
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

"richb330" <ri******@hotmail.com> wrote in message
news:OM**************@TK2MSFTNGP15.phx.gbl...
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.

"Lon" <lo*@apcare.net> wrote in message
news:OQ**************@TK2MSFTNGP14.phx.gbl...
You need to have the following code before the Module "modulename" line:

Imports System.DirectoryServices

"richb330" <ri******@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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



Nov 21 '05 #4

P: n/a
ah, many thanks.

got it now.
"Lon" <lo*@apcare.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

"richb330" <ri******@hotmail.com> wrote in message
news:OM**************@TK2MSFTNGP15.phx.gbl...
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.

"Lon" <lo*@apcare.net> wrote in message
news:OQ**************@TK2MSFTNGP14.phx.gbl...
You need to have the following code before the Module "modulename" line:

Imports System.DirectoryServices

"richb330" <ri******@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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




Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.