Re: ADSI ans Visual Basic .NET 2005



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.


.



Relevant Pages

  • Re: ADSI
    ... Joe Kaplan-MS MVP Directory Services Programming ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ... I have question about Active Directory. ... users on SQL server 2005 associated with roles, ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: ADSI ans Visual Basic .NET 2005
    ... Thank you Joe, it worked. ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ... vbscript into visual basic .net 2005 with no luck whatsoever. ... The Active Directory object located at ...
    (microsoft.public.windows.server.active_directory)
  • Re: Web Single Sign On
    ... Joe Kaplan-MS MVP Directory Services Programming ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ... current Windows credentials to the server, ... This common identity is the user's username used to logon to the ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Changing ADAM user password
    ... Joe Kaplan-MS MVP Directory Services Programming ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ... Running the bind from another W2K3SP1 machine ... support in digest or something like that. ...
    (microsoft.public.windows.server.active_directory)
  • Re: Secure SSL with LDAP and AD
    ... Joe Kaplan-MS MVP Directory Services Programming ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ... LDAP over SSL with a third-party certification authority. ... Note that a self signed cert is probably a very poor choice as nothing ...
    (microsoft.public.windows.server.security)