• Home
  • About
  • BestBloggingIdeas
  • DotNetLearningSource
  • FORUM
  • Joblinks
  • Latest News
  • Policy
  • POSTS
  • SimplySqlServer.Com && SimplyAspDotNet.Com
  • Sitemap

Join Ours Forum

Asp.Net,C#,Ajax,Sql server,silverlight,Javascript codes exambles articles,Programming exambles

RSS Feed
  • Bounty Huge Roll [Amazon Frustration-Free Packaging]
  • XML Introduction to XML VHS Video Training, 1 hr., 32 minutes.
  • The Basic Overview of Windows Mobile Development Asp.Net C#
  • Overview of Sql server extended properties Asp.Net C#
  • How to Use Sql Server Extended properties using visual studio Asp.Net C#
  • Adobe Dreamweaver Templates Accelerate Web Development
  • Top Tips for Web Design Projects
  • How to Achieve a Good Web Design Structure
  • To Use Or Not To Use Website Templates
  • Five Tips to a Successful Website
  • Top 10 Articles,


    Silverlight Datagrid Select Update Delete Insert Asp.Net C#

    Differences Similarities Benefits Between Typed Datasets and Untyped Datasets asp.net c#

    Linq to Sql Introduction Entities Ado.Net C# SqlClasses Attributes Linq Mapping

    Linq Programming/How Linq Works?/Linq Implementation In Asp.Net C# Ado.Net

    Performing Developing Using Investigating Asp.Net 2.0 Ajax Application Development Asp.Net C#

    Hosting/Install Wcf Services in a Windows Service Asp.Net C#

    Connecting Silverlight to Wcf Asp.Net C#

    Silverlight Data Grid Data Binding WCF Asp.Net C#

    Invoking/Accessing/Calling WCF Service Without Adding/Creating Proxy/Reference Asp.Net C#

    Performing Doing Creating Insert Update Delete sql data Using Linq Database Asp.Net C#

    How to authenticate a particular user machine in web services without using Userid&Password Authentication

    Posted by on June 26, 2010 Leave a comment (12) Go to comments

    Introduction:
    In this article,i am going to explain about how to authenticate web service into a particular client machine without using
    userid/password (stored in database).


    Main:

    Normally we know in windows/password based authentications we are using ip addess for validating windows account.
    so here also i tried the same ip address approach for authenticating particular client machine.

    Steps Involved,

    1.Store Client machine ip in config file,
    2.In Auth header i added extra field ‘ip’ for validating client machine ip address,
    3.In client side,i added the extra coding for getting ip address using system.net namespace.

    public class AuthHeader : SoapHeader
    {
    public string Username;
    public string Password;
    public string ip;

    }

    Web service sample code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using System.Web.Services.Protocols;
     
    namespace netprogWSex
    {
        /// <summary>
        /// Summary description for Service1
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [System.ComponentModel.ToolboxItem(false)]
        // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
        // [System.Web.Script.Services.ScriptService]
        public class Service1 : System.Web.Services.WebService
        {
            public AuthHeader Authentication;
     
            [SoapHeader("Authentication")]
            [WebMethod]
            public string WelcomeString()
            {
                if (Authentication.ip == "124.123.129.119")
                {
                    return "Welcome Client machine";
                }
                else
                {
                    if (Authentication.Username == "test" && Authentication.Password == "test")
                    {
                        return "I am Web Method";
     
                    }
     
                    else
                    {
                        return "You don't have access";
                    }
                }
     
                //return "ends";
            }
     
        }
     
        public class AuthHeader : SoapHeader
        {
            public string Username;
            public string Password;
            public string ip;
     
        }
    }

    Client sample code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ComponentModel;
    using System.Net;
     
    namespace WsClient
    {
        class Program
        {
            static void Main(string[] args)
            {
                ServiceReference2.AuthHeader authentication = new WsClient.ServiceReference2.AuthHeader();
                authentication.Username = "";
                authentication.Password = "";
     
                string strhost = Dns.GetHostName();
                string ipaddress1=null;
     
                //IPAddress[] addr = Dns.GetHostByName(strhost);
     
                IPHostEntry Local_Entry = Dns.GetHostByName(strhost);
                IPAddress[] addr = Local_Entry.AddressList;
     
                for (int i = 0; i < addr.Length; i++)
                {
                    ipaddress1 = addr[i].ToString();
                }
     
                authentication.ip = ipaddress1;
     
                WsClient.ServiceReference2.WelcomeStringRequest obj = new WsClient.ServiceReference2.WelcomeStringRequest();
                obj.AuthHeader = authentication;
     
                WsClient.ServiceReference2.WelcomeStringResponse objres = new WsClient.ServiceReference2.WelcomeStringResponse();
     
                WsClient.ServiceReference2.Service1SoapClient ong = new WsClient.ServiceReference2.Service1SoapClient();
                Console.WriteLine(ong.WelcomeString(authentication));
                Console.ReadLine();    
     
            }
        }
    }

    result

    Conclusion:

    Hope this helps,
    Happy Coding.

    WEB SERVICES
    ← How to use c#/csharp unsafe code in asp.net
    Create and Host/Use WCF applications in asp.net/c# Simple WCF Overview/Programming →

    Learn Easily Using Video Tutorials


    How to choose the right Java IDE – explained Eclipse NetBeans BlueJ

    Developing/Creating/Performing/Configuring Java Applications Using Eclipse IDE

    Step By Step Guide for Download/Install Configure Eclipse IDE for Java

    Editing data with the GridView control Asp.Net C#

    Registering/Configuring Web Controls globally in web.config file asp.net c#

    Registering/Configuring Web Controls globally in web.config file asp.net c#

    Best way to prepare asp.net Interview - Success Stories

    Download Important Questions and PPT's:

    Sql Server Important Questions Online free download

    Dotnet Important Questions Online free download

    Exploring Linq to Sql Process Flow

    Learn how to perform silverlight programming

    Learn OOPs concepts in better and well manner

    Learn Ajax in better and well manner

    Leave a comment

    12 Comments.

    1. how to make gold as a new level 80 June 27, 2010 at 9:43 pm

      Such a well written post.. Thnkx for sharing this post!

    2. ultrasound technician June 29, 2010 at 12:05 pm

      Wow this is a great resource.. I’m enjoying it.. good article

    3. Polly Goodwater July 3, 2010 at 10:49 am

      Thanks for the enthrilling article, can I ask where you get your sources from?

    4. GoldVish July 17, 2010 at 6:49 pm

      Properly, this really is my primary go to to your weblog! We are a group of volunteers and commencing a new initiative in a community in a similar niche. Your website supplied us useful details to function on. You’ve carried out a marvellous occupation!

    5. Smokeless Cigarettes July 18, 2010 at 9:30 pm

      Nice info, a lot of thanks towards the author. It really is incomprehensible to me now, but in basic, the usefulness and significance is overwhelming. Thanks again and very good luck!

    6. perfect optimizer review August 8, 2010 at 5:40 pm

      Thank you all and you for this great website, and i will bookmark this post, I was curious about this for a long time now. Do you have a rss feed that I can add? Have a fantastic day!

    7. Doradztwo kredytowe August 12, 2010 at 10:40 pm

      Excellent post I must say.. Simple but yet interesting and engaging.. Keep up the awesome work!

    8. advice to get my ex back August 14, 2010 at 3:53 pm

      found you on digg, darn happy I did, best post Ive read all day.

    9. cna training August 21, 2010 at 4:47 pm

      Keep posting stuff like this i really like it

    10. Strip Club Phoenix August 21, 2010 at 11:24 pm

      Keep up the amazing work!! I love how you wrote this and I also like the colors here on this site. Very good opinions expressed here :)

    11. assisted living December 13, 2010 at 7:20 pm

      this post is very usefull thx!

    12. where can i get zocor cheap May 2, 2011 at 1:33 am

      If you’re still on the fence: grab your favorite earphones, head down to a Best Buy and ask to plug them into a Zune then an iPod and see which one sounds better to you, and which interface makes you smile more. Then you’ll know which is right for you.

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    *

    *


    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

    Enter your email address:

    Delivered by FeedBurner

    • Recent Posts

      • Bounty Huge Roll [Amazon Frustration-Free Packaging]
      • XML Introduction to XML VHS Video Training, 1 hr., 32 minutes.
      • The Basic Overview of Windows Mobile Development Asp.Net C#
      • Overview of Sql server extended properties Asp.Net C#
      • How to Use Sql Server Extended properties using visual studio Asp.Net C#
    • Search by Tags!

      Application AspNet Basic between Black Bluetooth Build Business Collection Consultants Design Development Downloading effective Excel Experts Generics Implement Installing Interview Logic Management Microsoft Minutes Object Outlook Professional Programmer Programming Project Projects Questions Ready Select Server Services Silverlight Source Strings Studio Through using Visual Website Wordpress
    • Archives

      • August 2011
      • June 2011
      • May 2011
      • April 2011
      • March 2011
      • February 2011
      • December 2010
      • November 2010
      • October 2010
      • September 2010
      • August 2010
      • July 2010
      • June 2010
      • May 2010
      • April 2010
      • March 2010
      • February 2010
      • January 2010
      • December 2009
      • November 2009
      • October 2009
      • September 2009

    Copyright © 2012 NetProgrammingHelp.com

    Δ Top