[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

What are the Various approaches to get all users from Active Directory to SharePoint 2013 List.

Posted on 2014-08-09
5
Medium Priority
?
230 Views
Last Modified: 2014-08-20
I would like to get the list of Users and their details like ManagerName, EMail, etc. from Corporate Active Directory to SharePoint List 2013
0
Comment
Question by:Maheshkumar K
  • 3
  • 2
5 Comments
 
LVL 20

Expert Comment

by:Walter Curtis
ID: 40252357
Sounds as if you could use the user profile service. A built service that will replicate AD information and make it available to you via SharePoint.
0
 

Author Comment

by:Maheshkumar K
ID: 40261508
I want to get these information out from AD to SharePoint Custon List
0
 
LVL 20

Accepted Solution

by:
Walter Curtis earned 2000 total points
ID: 40262578
You can use PowerShell to read the information from AD and write that information to a SharePoint custom list.  There are scripts available just for that purpose from TechNet.
0
 

Author Comment

by:Maheshkumar K
ID: 40274573
Here is the working code:

#Add SharePoint PowerShell SnapIn if not already added
    if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
        Add-PSSnapin "Microsoft.SharePoint.PowerShell"
    }


    $site = new-object Microsoft.SharePoint.SPSite("http://ca1vmsp13dev:8005/");  
    $ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site);  
    $listName = "CustomUserProfileList"

    #Get UserProfileManager from the My Site Host Site context
    $ProfileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)    
    $AllProfiles = $ProfileManager.GetEnumerator()  

    $WebUrl = "http://ca1vmsp13dev:8005/"
    $web = Get-SPWeb $webUrl
    $list = $web.Lists[$listName]

    foreach($profile in $AllProfiles)  
    {  
        $DisplayName = $profile.DisplayName  
        $AccountName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value
        $ManagerName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::Manager].Value    


        $newItem = $list.AddItem()
        $newItem["EmployeeName"] = $DisplayName
        $newItem["EmployeeNTAccount"] = $AccountName
        $newItem["SupervisorNTAccount"] = $ManagerName
        $newItem.Update()

        #Here goes writing Logic to your SharePoint List + Check if account already existing in the SharePoint list then ignore writing.......
        write-host "---------------------------------------------------------"
        write-host "DisplayName for account ", $DisplayName
        write-host "Profile for account ", $AccountName
        write-host "Profile for account ", $ManagerName
        write-host "---------------------------------------------------------"

    }  
    write-host "Finished."
    $site.Dispose()
    $web.Dispose()
0
 
LVL 20

Expert Comment

by:Walter Curtis
ID: 40275586
Glad that worked for you. Thanks for the acceptance.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
While opting for any web-to-print solution, you need to discuss with your team and some of your end users and know their opinions about your decisions. In this article we list down some questions you need to ask yourself.
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Suggested Courses

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question