This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Help! Looking for a C# .NET sample code for adding a user into a AD group.

I am using .net to make a call to add users to a group. A sample is pasted below. When I execute this code, got "Unknown error (0x80041069)" error. Could anyone review my code and provide a sample code?

Thanks.

Kevin

CModifyRequest modifyRequest = new CModifyRequest();

modifyRequest.returnData = "everything";

//--
CPSOID psoID = new CPSOID
{
ID = "CN=group1,OU=IT,DC=dc1,DC=win,DC=company,DC=com"
};

modifyRequest.psoID = psoID;


List<modification> modif = new List<modification>();

modif.Add(CreateModification("member", "add", new object[] { "CN=user1,OU=IT,DC=dc1,DC=win,DC=company,DC=com" }));


modifyRequest.modification = modif.ToArray();

//-- Create web service instance
ActiveRolesSPMLProviderSoapClient webService = new ActiveRolesSPMLProviderSoapClient();

webService.ClientCredentials.UserName.UserName = @"userName";
webService.ClientCredentials.UserName.Password = @"password";


//-- Send request and get response
CModifyResponse myresponse = webService.modify(modifyRequest);

///---- CreateModification function

modification CreateModification(string name, string operation, object[] values)
{
modification modif = new modification
{
operation = operation,
name = name,
value = values
};

return modif;
}