Re: ADSI ans Visual Basic .NET 2005
- From: "Joe Kaplan" <joseph.e.kaplan@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 17 Nov 2006 16:57:08 -0600
You can't do it like that, as the object isn't a child of the group (as in
the OU hierarchy), but is a member of it. You need to invoke the Add
method:
Try something like this instead:
Dim oAdminGroup As New DirectoryEntry("WinNT://ServerName/Administrators")
oAdminGroup.Invoke("Add", New Object()
{"WinNT://Domain/SecurityGroup,group"})
oAdminGroup.CommitChanges()
It is a little funky with the syntax as you have to use the Invoke method
which is actually calling down into COM to call the IADsGroup.Add method.
DirectoryEntry doesn't directly support the properties and methods on
interfaces like IADsUser and IADsGroup, just IADs.
Note that I'm not really a WinNT provider kind of guy, just an LDAP guy, but
I think something about like this should work.
Joe K.
--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
"glassman324" <glassman324@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:68F95BE0-F67C-44B0-8ED1-0ECFECDAD8D7@xxxxxxxxxxxxxxxx
I have been trying for most of the day now to transform the following
vbscript into visual basic .net 2005 with no luck whatsoever. The script
adds an existing security group in active directory into a remote
computer's
Administrators group.
vbscript
Set oAdminGroup = GetObject("WinNT://ServerName/Administrators,group")
oAdminGroup.Add "WinNT://Domain/SecurityGroup,group"
Call oAdminGroup.SetInfo
visual basice .net 2005
Dim oAdminGroup As New DirectoryEntry("WinNT://ServerName/Administrators")
AD.Children.Add(SecurityGroup, "group")
AD.CommitChanges()
The following Error is what I receive:
System.InvalidOperationException: The Active Directory object located at
the
path WinNT://ServerName/Administrators is not a container.
Any thoughts would be great. Thanks.
.
- Follow-Ups:
- Re: ADSI ans Visual Basic .NET 2005
- From: glassman324
- Re: ADSI ans Visual Basic .NET 2005
- Prev by Date: Re: Forward lookup zone not automatically created for new domain i
- Next by Date: Re: Forward lookup zone not automatically created for new domain i
- Previous by thread: Re-joining workstations to new domain controller
- Next by thread: Re: ADSI ans Visual Basic .NET 2005
- Index(es):
Relevant Pages
|