Pwogramasyon Add itilizatè charepwen Gwoup

To assign the user to group in MOSS 2007

The following code will add the user to site and to specified group.

private void AddUser(string strSite,string webGroup)
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
lè l sèvi avèk (SPSite site = new SPSite(strSite))
{
lè l sèvi avèk (SPWeb web = site.OpenWeb())
{
Boolean allowUnsafeUpdate = web.AllowUnsafeUpdates;
eseye
{
web.AllowUnsafeUpdates = true;

web.SiteUsers.Add(loginName, MailId, loginId, “”);
web.Groups[webGroup].AddUser(loginName, MailId, loginId, “”);

}
finally
{
web.AllowUnsafeUpdates = allowUnsafeUpdate;
}
}
}
});
}

Leave a Reply

Ou kapab sèvi ak sa yo tags HTML

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>