我如何从我的自定义列表中获取 peoples 并授予他们对我创建的子站点的权限。
public override void ItemAdded(SPItemEventProperties properties)
{
base.ItemAdded(properties);
我知道我需要从这个属性中得到它,但我不知道如何。阅读了大约 20 篇博客,但无法从这里找到。
string subsitefirst = properties.ListItem["firstSub"].ToString();
string subsitesecond = properties.ListItem["secondSub"].ToString();
//take 1st and 2nd fields name and create with them subsites.
if (string.IsNullOrEmpty(subsitefirst) && string.IsNullOrEmpty(subsitesecond))
{
return;
}
else
{
using (SPSite site = new SPSite("http://sw-mss-01:23222/Worker1/"))
{
using (SPWeb web = site.OpenWeb())
{
try
{
//SPListItem listpeople = web.GetListItem
web.AllowUnsafeUpdates = true;
SPWeb newWeb = site.AllWebs.Add("worker1/" + subsitefirst, subsitefirst, "Site description", 1033, "STS#0", false, false);
SPWeb newSecondWeb = site.AllWebs.Add("worker1/" + subsitefirst + "/" + subsitesecond, subsitesecond, "Site description", 1033, "STS#0", false, false);
}
catch (Exception)
{
web.AllowUnsafeUpdates = false;
}
}`
}
}
}
}