I’m trying to create user group for registered in SQL Server 2008.
This is my code :
[DllImport("Netapi32.dll", CharSet=CharSet.Unicode)]
internal static extern int NetLocalGroupAdd([In, MarsharAS(UnmanagedType.LPWStr)] string serverName,[In] int level, [In] reg NativeHeaders.LOCALGROUP_INFO_1 info0, out int paramError);
internal struct LOCALGROUP_INFO_1
{
public string lgrpi1_name;
public string lgrpi1_comment;
}
$ always return error number 2202( User name not valid )
Public void CreateWinAuthGroup ()
{
var localgroup_info_ = new LOCALGROUP_INFO_1
{
lgrpi1_name = "TesUserGroup",
lgrpi1_comment = "Group for My Application"
}
int error = NetLocalGroupAdd(serverName, 0, ref localgroup_info_, out paramerror);
}
Has anyone else faced this issue? This source running well on my standalone test application. But always returns error when integrated with main application.
Thanks for any help.
Found the error.it’s because I doing testing using my custom string group user name. so it will be running well. but on real class, error is because username group format not valid. error 2202 is : error number description for Terminal Server . So the problem is closed.