473,396 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

import dll issue

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
4 2748
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bram Stolk | last post by:
Hello, I am using python-2.2.2 on linux-ARM. Python itself works OK. However, importing pickle gives me *very* strange results: The first 'import pickle' fails with "ImportError: No module...
16
by: Manlio Perillo | last post by:
Hi. I'm a new user of Python but I have noted a little problem. Python is a very good language but it is evolving, in particular its library is evolving. This can be a problem when, ad example,...
97
by: Kjetil Torgrim Homme | last post by:
often when re-factoring code, I need to change the indent level of some chunk of code. due to the lack of an end marker, my Emacs has to use heuristics when re-indenting, and this will...
4
by: news | last post by:
Our production database in an exported textfil runs about 60 MB. Compressed that's about 9 MB. I'm trying to import the export into another machine running FC3 and mySQL 11.18, and it appears as...
3
by: Anthony Robinson | last post by:
I have an issue I've been working on that has proven to be quite troublesome. I already have an idea of what the anwser may be, but would like to solicit some suggestions or other ideas from you...
4
by: aj | last post by:
Red Hat Linux AS 2.1 DB2 WSE 8.1 FP5 I installed FP5 on my v8 server this weekend, and I think I have found a new bug in the DB2 IMPORT command. Previously, I would issue a SET SCHEMA...
4
by: Steve Jorgensen | last post by:
I'm restarting this thread with a different focus. The project I'm working on now id coming along and will be made to work, and it's too late to start over with a new strategy. Still, I'm not...
4
by: N. Graves | last post by:
Thanks for taking the time to read this note. I have a Access inventory collection tool that I have automated to build and Export to a CSV file. In the database I have several fields that are...
2
by: Bill Jackson | last post by:
Once again, I am having issues with imports... Until now, I thought the general guidelines were to rarely use 'from x import y' syntax, except when you really want to copy names over. However, I...
5
geolemon
by: geolemon | last post by:
Import text wizard says: I'm banging my head on this one, here's why: I've been importing files using this process and data format, with success! I created a temporary table in Access to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.