From: Dan Crossett on
I want to add a domain account to a local group during my setup process. At
this point the computer has joined the domain but is not logged into it.
I've tried using the DirectoryEntry object without success.


Dim sUserDN As String = "CN=Me,OU=MyOU,DC=MyDom,DC=com"
Dim deUser As New
System.DirectoryServices.DirectoryEntry("LDAP://MyDom.Com/" & sUserDN,
"Admin", "password", DirectoryServices.AuthenticationTypes.Secure)

Dim deLocal As New DirectoryServices.DirectoryEntry("WinNT://" +
Environment.MachineName + ",computer")
Dim deGroup As DirectoryServices.DirectoryEntry

deGroup = deLocal.Children.Find("Administrators", "group")

deGroup.Invoke("Add", New Object(), deUser.Name.ToString)
' Error goes here :)

From: Bob Butler on

"Dan Crossett" <DanCrossett(a)discussions.microsoft.com> wrote in message
news:4ED3E07E-CFC9-4923-8765-3169FE62CDAA(a)microsoft.com...
>I want to add a domain account to a local group during my setup process.
>At
> this point the computer has joined the domain but is not logged into it.
> I've tried using the DirectoryEntry object without success.
>
>
> Dim sUserDN As String = "CN=Me,OU=MyOU,DC=MyDom,DC=com"

This group is for VB 6 and earlier; you need to find a group that deals
with VB.Net


From: Paul Clement on
On Tue, 13 Jul 2010 10:32:12 -0700, Dan Crossett <DanCrossett(a)discussions.microsoft.com> wrote:

� I want to add a domain account to a local group during my setup process. At
� this point the computer has joined the domain but is not logged into it.
� I've tried using the DirectoryEntry object without success.


� Dim sUserDN As String = "CN=Me,OU=MyOU,DC=MyDom,DC=com"
� Dim deUser As New
� System.DirectoryServices.DirectoryEntry("LDAP://MyDom.Com/" & sUserDN,
� "Admin", "password", DirectoryServices.AuthenticationTypes.Secure)

� Dim deLocal As New DirectoryServices.DirectoryEntry("WinNT://" +
� Environment.MachineName + ",computer")
� Dim deGroup As DirectoryServices.DirectoryEntry

� deGroup = deLocal.Children.Find("Administrators", "group")

� deGroup.Invoke("Add", New Object(), deUser.Name.ToString)
� ' Error goes here :)

Post this question to the Visual Basic General MSDN forum:

http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/threads?page=1

I would mention any meaningful error messages as well (not that this namespace library actually
provides any).


Paul
~~~~
Microsoft MVP (Visual Basic)
From: Dee Earley on
On 13/07/2010 18:38, Bob Butler wrote:
>
> "Dan Crossett" <DanCrossett(a)discussions.microsoft.com> wrote in message
> news:4ED3E07E-CFC9-4923-8765-3169FE62CDAA(a)microsoft.com...
>> I want to add a domain account to a local group during my setup
>> process. At
>> this point the computer has joined the domain but is not logged into it.
>> I've tried using the DirectoryEntry object without success.
>>
>>
>> Dim sUserDN As String = "CN=Me,OU=MyOU,DC=MyDom,DC=com"
>
> This group is for VB 6 and earlier; you need to find a group that deals
> with VB.Net

Or, more likely a DirectoryServices/Windows sysadmin group.

--
Dee Earley (dee.earley(a)icode.co.uk)
i-Catcher Development Team

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)