locked
Rewrite "P-Asserted-Identity" with MSPL RRS feed

  • Question

  • I am lookng for a way to rewrite "P-Asserted-Identity" content when a condition is met. This far, I cannot find any info. Is this possible at all or I am wasting my time?

    Thanks,

    Drago

    Friday, October 23, 2009 7:36 PM

All replies

  • Does anyone from Microsoft even reads this forum?
    Sunday, October 25, 2009 7:59 PM
  • You should be able to do this using an app on the server.  You might be able to do this in MSPL directly or, depending on the complexity of what you want to change, you might need to call out to a managed code app from the script.



    Oscar Newkerk Consultant
    • Proposed as answer by Oscarn Tuesday, October 27, 2009 9:06 PM
    Tuesday, October 27, 2009 9:06 PM
  • This indeed answers the first part of the question - Is it possible. Here where I am thus far:
    ===========================================

    <?xml version="1.0"?>
    <lc:applicationManifest
     lc:appUri="http://my_ocs_server.domain.local/Test"
     xmlns:lc="http://schemas.microsoft.com/lcs/2006/05">
    <lc:allowRegistrationBeforeUserServices action="true" />
    <lc:requestFilter methodNames="INVITE"
       strictRoute="false"
       registrarGenerated="true"
       domainSupported="true" />
    <lc:responseFilter reasonCodes="NONE" />
    <lc:proxyByDefault action="true" />
    <lc:scriptOnly />
    <lc:splScript><![CDATA[

    Log("Event", true, "RequestUri is: ",sipRequest.RequestUri );

        // Check if this is a re-INVITE and exit if so
        foreach ( sessionExpires in GetHeaderValues( "Session-Expires" ) ) {
            if ( ContainsString( sessionExpires, "refresher", true ) ) {
    //Log( "Event", false, "RespondWithRinging:         * skipped; This is a session refreshing invite" );
                return;
            }
        }

        if (sipRequest.RequestUri == "sip:+911@domain.local;user=phone")
            {
    Log("Event", true, "911, changing to Test Number");

            ProxyRequest("sip:+15551234567@my_mediation_server.domain.local:5061;user=phone;maddr=my_mediation_server.domain.local");
           
            }
                   
    ]]></lc:splScript>
    </lc:applicationManifest>

    ============================================

    This works. When 911 is dialed from inside, the actual number that leaves the domain and goes to the SIP Trunk provider  is 15551234567

    We need P-Asserted_Identity rewritten, so in case of 911, the BTN (our only E911 DID) will be presented, the provider will route the call to the local emergency center (instead of the National Emergency Center, which in return will dial the local one) and $50 charge will not occur.

    This is where I need hepl, since I cannot find anything related to P-Asserted-Identity manipulation in the MSPL documentation.


    Drago

    Wednesday, October 28, 2009 3:12 AM
  • There is nothing in the MSPL documentation on the P-Asserted-Identity header specifically.  You can access all the headers in the request.

    From the MSPL docs:

    In an MSPL script you can get a header value using:

    collection<string> GetHeaderValues(
    string or StandardHeader value headerName
    );
    You can set the header value using SetParameterValue();

    In managed code use:

    public void OnRequest(object sender, RequestReceivedEventArgs rreArgs)
    {
    Request r = rreArgs.Request;
    HeaderCollection headers = r.AllHeaders;
    foreach (Header header in headers)
    {
    Console.WriteLine("{0}: {1}", header.Type, header.Value);
    }
    }
    Once you get the header, then you can modify the value.

    Oscar Newkerk Consultant
    • Proposed as answer by Oscarn Friday, October 30, 2009 8:21 PM
    Friday, October 30, 2009 8:21 PM
  • Oscar,

    PAI = GetHeaderValues( "P-Asserted-Identity" ); returns the proper string.

    Let's assume I want to have new PAI as "GMC", "<sip:gmc@my_doamin>,<tel:+15550000000>" );


    When I use:

    PAI2 = Concatenate( "\"GMC\"", "<sip:gmc@my_domain>,<tel:+15550000000>" );

    AddHeader ("P-Asserted-Identity", PAI2);

     - this adds second header with the new value bit of course this does not work because we have now two P-Asserted-Identity headers with different values.



    I cannot figure out the proper syntax for SetParameterValue() since we must rewrite, not add...

    Any hints?


    Drago
    Saturday, October 31, 2009 4:34 PM
  • I think that you need to call out to the managed code module to modify the headers.

    In managed code you can use HeaderCollection.Remove() to delete the value and HeaderColllection.Insert() to put in your modified value.




    Oscar Newkerk Consultant
    • Proposed as answer by Oscarn Sunday, November 1, 2009 6:33 PM
    Sunday, November 1, 2009 6:32 PM
  • I was hoping a managed code will not be needed :-) Here goes my weekend...

    Thanks a lot!

    Drago
    Sunday, November 1, 2009 6:36 PM
  • Hi Drago,

    have you managed to modify the header!?

    We are facing the same problem over here, maybe you can help us save some time on this ;)

    Bests

    Dennis

    Tuesday, November 29, 2011 10:19 AM
  • Dennis,

    Actually, I have dropped the project, because we deployed SBC and did it on the gateway. Are you using OCS or Lync?



    Drago

    http://www.lynclog.com
    Tuesday, November 29, 2011 1:28 PM
  • We are implementing Lync right now, also trying to set up SBC for it, but having some trouble with PAI..

    /Dennis

    Tuesday, November 29, 2011 2:18 PM
  • If your goal is to handle 911, this is easily achievable with Lync by using separate Trunk and rewrite the outbound caller id. Get wil me via email - dtotev at lynclog.com to discuss...

     

    Drago


    http://www.lynclog.com
    Tuesday, November 29, 2011 2:29 PM