string strUserName = "kevin";
SPSite siteCollection = SPControl.GetContextSite(Context);
siteCollection.AllowUnsafeUpdates = true;
SPWeb web = siteCollection.AllWebs["testByjason10"];
web.AllowUnsafeUpdates = true;
SPRoleCollection rols = web.Roles ;
foreach(SPRole r in rols)
{
Response.Write (r.Name);
}
SPRole designerRole = web.Roles["Contributor"];
designerRole.AddUser("RELEASE-SERVER\\"+strUserName,"
123@123.com","RELEASE-SERVER\\"+strUserName,"kevin");
转载于:https://www.cnblogs.com/lingxzg/archive/2007/06/08/776925.html