Page view counter

How to re use authenticated user name and password of sharepoint site in NetworkCredential() method as parameters

Last post 01-31-2007 8:52 PM by Leijun Jie - MSFT. 1 replies.

Sort Posts:

  • How to re use authenticated user name and password of sharepoint site in NetworkCredential() method as parameters

    01-25-2007, 4:02 AM
    • Loading...
    • rmpasha
    • Joined on 08-14-2006, 9:39 AM
    • Kathmandu, Nepal
    • Posts 19
    • Points 43

    I am creating a user control page(ascx) using the web services from SharePoint Services/Project Server site. As we know that the user name and password needs to access the sites of them. I
    used the following code(C#) to access the web services, it will work fine. There is already Windows Authentication in Sharepoint Site.

    //UserGroupWS is Added Web Service
    private static UserGroupWS.UserGroup userGroup = new UserGroupWS.UserGroup();

    userGroup.Url = "http://DomainName/_vti_bin/UserGroup.asmx";

    userGroup.Credentials = new System.Net.NetworkCredential("UserName", "Password", "DomainName");

    Note that there are the parameters namded "Password" also in NetworkCredential() method. While this page is using as webpart in SharePoint Site, I can access the UserName currently logined to pass as first parameter in this method. But how to retrieve Password of the current UserName currently logined to pass as second parameter in this method? Is there any idea?

    Please help!!!

  • Re: How to re use authenticated user name and password of sharepoint site in NetworkCredential() method as parameters

    01-31-2007, 8:52 PM
    If you want to pass current Windows Identity, why not try System.Net.CredentialCache.DefaultCredentials? For example:

    userGroup.Credentials = System.Net.CredentialCache.DefaultCredentials;
    The future is now...
    Sincerely,
    LeiJun Jie
    Microsoft Online Community Support
Page 1 of 1 (2 items)