Hi

I want to create a window local user and add it to a group (using asp.net
& C#).

Upto creating new user my code works fine but when I try to add this user
to a group then it gives following error (Error occurr only on my
production server. On test server it works fine):

***********************************************************************
Error Message: Exception has been thrown by the target of an invocation.

Error Source: mscorlib

InnerException: System.Runtime.InteropServices.COMException (0x8007056B):
A member could not be added to or removed from the local group because the
member does not exist.

BaseException: System.Runtime.InteropServices.COMException (0x8007056B): A
member could not be added to or removed from the local group because the
member does not exist.
************************************************************************


I also add a window user manually and then try to put it programmatically
into a group but get the same error.

Any help?
Thanks in advance.
Regards
Aftab

Below is complete example of my code:

DirectoryEntry AD = new DirectoryEntry("WinNT://172.30.30.12");
AD.AuthenticationType = AuthenticationTypes.Secure;
AD.Username = "administrator";
AD.Password = "pwd12345";

DirectoryEntry NewUser = AD.Children.Add(userID, "user");
NewUser.Invoke("SetPassword", new object[] {"#" + password});
NewUser.Invoke("Put", new object[] {"Description", "Test User from .NET"});
NewUser.CommitChanges();
lblErrors.Text = "Account Created Successfully<br>";

DirectoryEntry grp = AD.Children.Find("SSL_Users", "group");

if (grp != null)
{
 grp.Invoke("Add", new object[] {NewUser.Path.ToString()});//ERROR
LINE
}
else
{
 lblErrors.Text += "<br><br>User or group not exists";
}
lblErrors.Text += "User Added to Group Successfully";
}
catch (Exception ex)
{
 lblErrors.Text += "<br>Error Message:" + ex.Message
 + "<br><br>Error Source: " + ex.Source
 + "<br>InnerException: " + ex.InnerException
 + "<br><br>BaseException: " + ex.GetBaseException()
}

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to