-----------------------------------------------------------

New Message on cochindotnet

-----------------------------------------------------------
From: Z?ón
Message 2 in Discussion

Hema,   First of all you need to see if you can view any existing group 
objects.  You would be using the DirectoryEntry objects for this. 

Now when connecting to ActiveDirectory services you need to specify a provider 
Here the the provider is LDAP.  If you want to use LDAP you made sure the 
server your are trying to create the user on has a LDAP service running. 
Basically if Active Directory is installed then its possible. 

If you just want to add a local use to a local group then you can even use the 
WinNT provider.  private void AddUser(string strDoamin, string strLogin, string 
strPwd)
{
    DirectoryEntry obDirEntry = null;
    try
    {
        obDirEntry = new DirectoryEntry("WinNT://" + strDoamin);
        DirectoryEntries entries = obDirEntry.Children;
        DirectoryEntry obUser = entries.Add(strLogin, "User");
        obUser.Properties["FullName"].Add("Amigo");
        object obRet = obUser.Invoke("SetPassword", strPwd);
        obUser.CommitChanges();
    }
    catch (Exception ex)
    {
        Trace.Warn(ex.Message);
    }
}   This would help you add and assign to the group Sub Main()
 Try
          Dim AD As DirectoryEntry = _
        New DirectoryEntry("WinNT://" + Environment.MachineName + ",computer")
         Dim NewUser As DirectoryEntry = AD.Children.Add("TestUser1", "user")
       NewUser.Invoke("SetPassword", New Object() {"#12345Abc"})
         NewUser.Invoke("Put", New Object() {"Description", "Test User from 
.NET"})
      NewUser.CommitChanges()
Dim grp As DirectoryEntry

           grp = AD.Children.Find("Guests", "group")
           If grp.Name <> "" Then
             grp.Invoke("Add", New Object() {NewUser.Path.ToString()})
          End If
Console.WriteLine("Account Created Successfully")
Console.ReadLine()

Catch ex As Exception
          Console.WriteLine(ex.Message)
          Console.ReadLine()
End Try
End Sub
 Hope this helps. 

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/Cochindotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to