using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Security.Principal;

public partial class UserDefinedFunctions
{
    [Microsoft.SqlServer.Server.SqlFunction]
    [return: SqlFacet(Precision = 9, Scale = 2)]
    public static decimal GetStockWS(string symbol)
    {
        WindowsImpersonationContext c = SqlContext.WindowsIdentity.Impersonate();
        Service s = new Service();
        s.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
        return s.GetStockPrice(symbol);
    }
};

