Web Service UseDefaultCredientials = False

jwilderjwilder Member Posts: 263
edited 2011-10-06 in NAV Three Tier
I would like to turn UseDefaultCredentials off. For example the C sharp code would be:

Letters ws = new Letters();
ws.UseDefaultCredentials = false;
ws.Url = "http://swk-lab2:7047/DynamicsNAV/WS/MyCompany/Codeunit/Letters";
etc...


How do I manually set a user id + password to pass to SQL?

ws.Credentials looks promising but what are the parameters?

Comments

  • freddy.dkfreddy.dk Member, Microsoft Employee Posts: 360
    ws.Credentials = new System.Net.NetworkCredential(user,password [, domain]);
    Freddy Kristiansen
    Group Program Manager, Client
    Microsoft Dynamics NAV
    http://blogs.msdn.com/freddyk

    The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
  • kinekine Member Posts: 12,562
    May be something like Credential.Create(UserName,Password)?

    See http://technet.microsoft.com/es-es/libr ... 513(SQL.90).aspx
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • jwilderjwilder Member Posts: 263
    This is exactly what I need. Thanks!
  • kinekine Member Posts: 12,562
    I missed Freddy's post. His solution is the correct one (jut for others to make it clear). 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • jwilderjwilder Member Posts: 263
    Funny, I missed your post Kamil. I was talking about Freddy's post as well.
  • philipuskdphilipuskd Member Posts: 36
    kine wrote:
    May be something like Credential.Create(UserName,Password)?

    See http://technet.microsoft.com/es-es/libr ... 513(SQL.90).aspx

    I've tried using this syntax but no luck.

    All parameters are in string, so, I assume, I just need to replace each parameters with user, password and domain of the server. The question is, which user i need to use here? the one that in Windows Login (in Classic NAV Client) or any domain user?

    is there any other syntax should be placed before / after the above syntax? since in my testing environtment, the syntax above doen't work.

    thx in advance.
  • kinekine Member Posts: 12,562
    It must be account having enough rights within NAV...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • BeliasBelias Member Posts: 2,998
    philipuskd wrote:
    kine wrote:
    May be something like Credential.Create(UserName,Password)?

    See http://technet.microsoft.com/es-es/libr ... 513(SQL.90).aspx

    I've tried using this syntax but no luck.

    All parameters are in string, so, I assume, I just need to replace each parameters with user, password and domain of the server. The question is, which user i need to use here? the one that in Windows Login (in Classic NAV Client) or any domain user?

    is there any other syntax should be placed before / after the above syntax? since in my testing environtment, the syntax above doen't work.

    thx in advance.
    because you have looked at the wrong syntax! ;) (the correct one should be the one written by freddy.dk)

    ws.Credentials = new System.Net.NetworkCredential(user,password [, domain]);
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • philipuskdphilipuskd Member Posts: 36
    oops, wrong quote :oops:

    i've been using this code actually:
    ws.Credentials = new System.Net.NetworkCredential("administrator","P@ssw0rd","NAV");
    The unauthorize error keeps on happening when i call the readmultiple. NAV\administrator is a domain administrator and SUPER user in NAV.

    one more question, when using UseDefaultCredentials, what credential the applicatioin actually using? is it the domain user which is used to logged into windows? if it is, how if the user is outside the domain environtment, let say they access the web application on www which consume the NAV webservice. All I can think of is using above syntax. if so, I must make the code above works :)

    is there anything i missed?

    thx
  • philipuskdphilipuskd Member Posts: 36
    I found it. I remove the domain parameter, so i just only using 2 parameters, user name and password. but this raise another confusion. when do I need to use the domainname parameter or not? is new System.Net.NetworkCredential("administrator","P@ssw0rd"); automatically add the domain name information for the credentials?

    the second question is still open thou:
    when using UseDefaultCredentials, what credential the applicatioin actually using? is it the domain user which is used to logged into windows? if it is, how if the user is outside the domain environtment, let say they access the web application on www which consume the NAV webservice. All I can think of is using above syntax.

    in that case, i do really need to know how the above syntax works.

    is there any clue?

    Thx
Sign In or Register to comment.