Bulk add Shaepoint users with email address
I have a MOSS 2007 farm. I have an Excel spreadsheet with 1000+ email addresses in it. I need to add all of these users to a SharePoint group. Any suggestions on the best way to do this without having to copy/paste the email addresses into the "Add User" screen in SharePoint. Can I use stsadm? C#? Powershell? jason
January 18th, 2012 10:25pm

If you have powershell installed on your MOSS 2007 server then you can use powershell command as shown here. Alternatively, you can create a c# console Application which reads say a XML file ( list of user email or user information ). The XML file can be like <Users> <User> <Name> XYZ </Name> <Email> zyx@somedomain.com </Email> </User> </Users> and the use the below c# code in the console app (you have to tweak this as needed) SPSite currentSiteT = SPContext.Current.Site; SPWeb currentWebT = currentSiteT.AllWebs["<your web name>"]; SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(currentSiteT.ID)) { using (SPWeb currentWeb = site.OpenWeb(currentWebT.ID)) { // add a for loop here which reads your xml file string userid = "hhh"; // read this from xml SPUser requireduser = currentWeb.EnsureUser(userid); currentWeb.Groups["TestGroup"].AddUser("domain\\abc", "abc@domain.com", null, null); } } }); If you wish to add users using the service you can again do so as shown here Priyanka
Free Windows Admin Tool Kit Click here and download it now
January 19th, 2012 2:25am

The problem is I do not have the users ID. All I have is 1000 email addresses. And those addresses span 4 different trusted domains across two active directory forests. Each forest and/or domain uses a differnt naming standard so there is no way for me to calculate the user id. I could try and look up the ID using LDAP or C# directory library but that has not worked well in the past. Can I do a bulk add without the user ID?jason
January 19th, 2012 2:47am

I am afraid that it might be not possible to add user programatically (c#) without a userId ( not sure though). A thought - You can prepare a semicolon seperated list of users and add say 50 to 60 emails at the same time in the add user text box. Though, I am not sure about the max number of user email ids you could specify at a time, it would certainly help you move faster. Priyanka
Free Windows Admin Tool Kit Click here and download it now
January 19th, 2012 6:20am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics