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 'DirectryEntry' 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
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 'DirectryEntry' 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