webservice check credential

casanova
Member Posts: 194
hi all
how do I check credential in webservice to nav?
if user id is wrong then he/she cant login
i try this code but failed
how do I check credential in webservice to nav?
if user id is wrong then he/she cant login
i try this code but failed
try { domain = textBoxDomain.Text; uid = textBoxUserID.Text; pwd = textBoxPassword.Text; NetworkCredential credentials = new NetworkCredential(uid, pwd, domain); SystemService systemService = new SystemService(); systemService.Credentials = credentials; systemService.Url = baseURL + "SystemService"; systemService.PreAuthenticate = true; MessageBox.Show("Welcome " + uid.ToString()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); }
0
Comments
-
hai anything about this?
i need this too
thanks0 -
what is the error?0
-
there is no error
but i cant authenticate
because we cant check domain password from NAV or C#0 -
Hi casanova,casanova wrote:there is no error
but i cant authenticate
because we cant check domain password from NAV or C#
We no need to check domain password. We need to check login user is authenticate or not. And we can't check user id is wrong or password is incorrect. What we can do it, we can check login user is authenticate or not. Here is sampletry { string _strUrl = "http://localhost:7047/DynamicsNAV/ws/SystemService"; System.Net.WebRequest _webRequest = System.Net.WebRequest.Create(_strUrl); _webRequest.UseDefaultCredentials = false; _webRequest.Credentials = new System.Net.NetworkCredential("your-domain-login", "your-domain-password", "your-domain"); System.Net.HttpWebResponse _httpWebResponse = (System.Net.HttpWebResponse)_webRequest.GetResponse(); } catch (System.Net.WebException _webException) { string _Error = _webException.Message; if (_webException.Status == System.Net.WebExceptionStatus.ProtocolError) { System.Net.HttpWebResponse _httpWebResponse = (System.Net.HttpWebResponse)_webException.Response; if (_httpWebResponse != null) Console.WriteLine("HTTP Status Code: " + (int)_httpWebResponse.StatusCode); //401 authentication fail,503 ServiceUnavailable else { // no http status code available } } else { // no http status code available } }
Best Regards,
YukonMake Simple & Easy0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions