Home All Groups Group Topic Archive Search About

Add Active Directory Users to a Group on a Workstation

Author
22 Dec 2006 6:33 PM
whoopes
Found the following on Microsoft's website,
http://support.microsoft.com/kb/306271, but it only seems to work when
creating an account on a workstation.  I am new to VB.NET (2005).

TIA!

Show quoteHide quote
://Bill

Author
22 Dec 2006 6:41 PM
vbnetdev
are you asking to do it remotely?


<whoo***@gmail.com> wrote in message
Show quoteHide quote
news:1166812387.036004.126870@h40g2000cwb.googlegroups.com...
> Found the following on Microsoft's website,
> http://support.microsoft.com/kb/306271, but it only seems to work when
> creating an account on a workstation.  I am new to VB.NET (2005).
>
> TIA!
>
> ://Bill
>
Are all your drivers up to date? click for free checkup

Author
22 Dec 2006 7:42 PM
whoopes
Examples of both would be great, but locally is what I am looking for.


://Bill

vbnetdev wrote:
Show quoteHide quote
> are you asking to do it remotely?
>
>
> <whoo***@gmail.com> wrote in message
> news:1166812387.036004.126870@h40g2000cwb.googlegroups.com...
> > Found the following on Microsoft's website,
> > http://support.microsoft.com/kb/306271, but it only seems to work when
> > creating an account on a workstation.  I am new to VB.NET (2005).
> >
> > TIA!
> >
> > ://Bill
> >
Author
22 Dec 2006 8:22 PM
vbnetdev
Then I don't understand. The MS example should work for you locally.
what happens when you try?

<whoo***@gmail.com> wrote in message
Show quoteHide quote
news:1166816530.574041.251680@79g2000cws.googlegroups.com...
> Examples of both would be great, but locally is what I am looking for.
>
>
> ://Bill
>
> vbnetdev wrote:
>> are you asking to do it remotely?
>>
>>
>> <whoo***@gmail.com> wrote in message
>> news:1166812387.036004.126870@h40g2000cwb.googlegroups.com...
>> > Found the following on Microsoft's website,
>> > http://support.microsoft.com/kb/306271, but it only seems to work when
>> > creating an account on a workstation.  I am new to VB.NET (2005).
>> >
>> > TIA!
>> >
>> > ://Bill
>> >
>
Author
22 Dec 2006 8:53 PM
whoopes
THe following is my code which doesn't work:

    Sub Main()
        Dim AD As DirectoryEntry = New DirectoryEntry("WinNT://" +
Environment.MachineName + ",computer")
        Dim grp As DirectoryEntry

        grp = AD.Children.Find("Administrators", "group")

        If grp.Name <> "" Then
            Console.WriteLine("Going to add to group")
            grp.Invoke("Add", New Object() {"<domain>\<user>"})
        Else
            Console.WriteLine("Group does not exist")
        End If
    End Sub

Debugging says:  System.Reflection.TargetInvocationException was
unhandled

Thanks for working with me!
Author
23 Dec 2006 12:58 AM
whoopes
Bump...

What am I doing wrong??
Author
23 Dec 2006 5:47 AM
vbnetdev
What line did the error occured?

what does bump mean?

<whoo***@gmail.com> wrote in message
Show quoteHide quote
news:1166835510.700003.312640@f1g2000cwa.googlegroups.com...
> Bump...
>
> What am I doing wrong??
>
Author
23 Dec 2006 2:17 PM
whoopes
Dump just meant that I am trying to keep the post alive, hoping someone
else may see it.
It's erroring out at grp.Invoke("Add", New Object()
{"<domain>\<user>"})

Show quoteHide quote
://Bill
Author
23 Dec 2006 5:38 PM
whoopes
Figured it out.  Should be:

        Dim StrUserEntry As String
        StrUserEntry = "WinNT://<domain>/<server>/<userid>"

        Dim group As DirectoryEntry = New DirectoryEntry("WinNT://" +
Environment.MachineName + "/Administrators,group")

        group.Invoke("Add", New Object() {StrUserEntry})
        group.CommitChanges()

Bookmark and Share