none
How to programmatocally username and password based open sharepoint 2010 site ? RRS feed

  • Question

  • Hi,

              I want open sharepoint site username and password based programmatically using server object model (or) client object model.

    Thanks

    Regards

    Narasimman

    Monday, July 22, 2019 9:40 AM

All replies

  • Hi

    Server object model doesn't need credential since it runs on SharePoint server.

    For CSOM, below is an example.

    try
        {
    
            string strUserName="abc";
            string strPassword="123";
            ClientContext context = new ClientContext(siteurl);
            var credentials = new NetworkCredential(strUserName, strPassword,"Ext");
    
    
            context.Credentials = credentials;
            // The SharePoint web at the URL.
            Web web = context.Web;
    
            // We want to retrieve the web's properties.
            context.Load(web);
    
            // Execute the query to the server.
            context.ExecuteQuery();
    
            // Now, the web's properties are available and we could display 
            // web properties, such as title. 
            System.Console.WriteLine("Web Title");
            System.Console.WriteLine(web.Title);
        }
        catch (Exception ex)
        {
        }


    Justin Liu Office Apps & Services MVP, MCSE
    Senior Software Engineer
    Please Vote and Mark as Answer if it helps you.

    Tuesday, July 23, 2019 1:10 AM
  • Hi Justin Liu,

                     Thanks for your reply. The above code tried but not working in sharepoint 2010 site. while credential based open sharepoint site on browser activity. So I want exactily sign in as different user account any Code level server (or) Client object modelto login sharepoint 2010 site. If any anotherway to javascript (or) Rest api to lgoin different user credntial based in sharepoint login  site.

    Thanks in advance

    Regards

    by

    Narasimman

    Tuesday, July 23, 2019 5:44 AM
  • Hi Narasimman,

    If you use NetworkCredential to pass the credential, please hard code the username and password.

    Or I suggest you provide more information about your basic requirement for further research.

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Tuesday, July 23, 2019 8:21 AM
    Moderator
  • Hi Narasimman,

    Would you please provide us with an update on the status of your issue?

    Best Regards,
    Dennis

    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Thursday, July 25, 2019 8:35 AM
    Moderator