0

I've write a program to get site info in SharePoint,

        ClientContext clientContext = new ClientContext("ShareURL");
        Web site = clientContext.Web;
        clientContext.Load(site);
        clientContext.ExecuteQuery();
        ListCollection lists = clientContext.Web.Lists;
        clientContext.Load(lists);
        clientContext.ExecuteQuery();
        foreach (List list in lists)
        {
            if (list.NoCrawl || list.Hidden || list.BaseType.ToString() == "Survey")
            {
                continue;
            }
            if (list.BaseType.ToString() == "GenericList")
            {
                Console.WriteLine("List : " + list.Title);
            }
            else if (list.BaseType.ToString() == "DocumentLibrary" && list.Title.ToString() != "Images")
            {
                Console.WriteLine("Document : " + list.Title);
            }
        }

but now i need to get this site admin or owner user, e.g. Email, User name...

how can i get this?

ZivHus
  • 67
  • 1
  • 11
  • if you want the get information about current user you can check this out: https://social.msdn.microsoft.com/Forums/office/en-US/6c36915e-2848-42fb-b30f-8894a8944a2f/sharepoint-c-get-list-of-sites-on-which-user-has-permission-read-contribute-owner-admin?forum=sharepointdevelopmentprevious – Masoud Andalibi Dec 14 '16 at 09:14
  • i can't use SPSite, I using Microsoft.SharePoint.Client 14.0.0.0 – ZivHus Dec 14 '16 at 10:02
  • where can download SPSite reference dll file? – ZivHus Dec 14 '16 at 10:03
  • you can check this link out http://stackoverflow.com/questions/29633604/cannot-find-the-spsite-name-space – Masoud Andalibi Dec 14 '16 at 10:04
  • I've try to download SharePoint Server 2013 Client Components SDK and install but still can find this dll – ZivHus Dec 14 '16 at 10:09
  • SPSite lives in Microsoft.SharePoint (Microsoft.SharePoint.dll). All of the failures beyond that are part of the cascade of a missing reference. You should also check which .NET Framework you're running. Most development is done under 4.0 at the moment (not client profile) – Masoud Andalibi Dec 14 '16 at 10:10
  • oh i can using SPSite now, but when i run it will error Microsoft.SharePoint.Library can not found – ZivHus Dec 15 '16 at 02:26
  • Hi @Valkyriee I has use Microsoft.SharePoint.dll but when i running program it will error, it will show Microsoft.SharePoint.Library can not found, how can i fix this? – ZivHus Dec 22 '16 at 03:22
  • Hey, have you looked at this article? https://support.office.com/en-us/article/Fix-problems-opening-documents-in-SharePoint-libraries-31329fa1-4ad0-47fc-95d8-bb0c5b12a536 – Masoud Andalibi Dec 22 '16 at 05:31

1 Answers1

0

I'm not sure you can display info for site admin. If you are an admin and you want to get your own data here's how you can easily do it from the client side.
Code:

      <script type="text/javascript">
 ExecuteOrDelayUntilScriptLoaded(init,'sp.js');
   var currentUser;
       function init(){
        this.clientContext = new SP.ClientContext.get_current();
         this.oWeb = clientContext.get_web();
         currentUser = this.oWeb.get_currentUser();
         this.clientContext.load(currentUser);
        this.clientContext.executeQueryAsync(Function.createDelegate(this,this.onQuerySucceeded), Function.createDelegate(this,this.onQueryFailed));
}

 function onQuerySucceeded() {
var lUser = currentUser.get_loginName();
var result = lUser.split("\\")[1];
document.getElementById('userLoginName').innerHTML = result;
document.getElementById('userId').innerHTML = currentUser.get_id();
document.getElementById('userTitle').innerHTML = currentUser.get_title();
document.getElementById('userEmail').innerHTML = currentUser.get_email();
 }

function onQueryFailed(sender, args) {
alert('Request failed. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace());
  }

    <div>Current Logged User:
         <span id="userLoginName"></span>
         <span id="userId"></span>
         <span id="userTitle"></span>
         <span id="userEmail"></span> 
     </div>


This will display the user info for any logged on user.

Adi Solar
  • 127
  • 1
  • 1
  • 13