Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7657859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:07:05+00:00 2026-05-31T13:07:05+00:00

Since I really don’t get any progress in the last hours I need to

  • 0

Since I really don’t get any progress in the last hours I need to consult you for a problem which I don’t get solved.
We have a Win CE 5.0 application, written C#/Compact Frmaework 2.0 that uses RASDial to Dial into a VPN. Currently it uses PPTP but I have to change it to L2TP with a Pre Shard Key. But to be honest I have no experience in C++ and I really understand only half of the code or to be more clear I don’t understand the RAS Api and Documentation in the MSDN.
I understand how to create this L2PT RAS Entry and how to Dial it but in no way I understand where and how to set the Pre Shared Key!
I found a peace of code that seems to do the same things our code does in priciple but on the Website/Board I found it the Author says this is with pre shared key but to be honest, I don’t get where the key is.

(…)

// Device configuration for L2TP VPN 
if (bIsL2TP) { 
    DWORD cbKey = 0; 
    if (g_sharedKey) { 
        cbKey = (wcslen(g_sharedKey))*sizeof(WCHAR); 
    } 
    pL2TPConfigData = (PL2TP_CONFIG_DATA)new BYTE 
[sizeof(L2TP_CONFIG_DATA)+ cbKey]; 


    ZeroMemory(pL2TPConfigData, sizeof(L2TP_CONFIG_DATA)+ cbKey); 
    pL2TPConfigData->dwVersion = 1; 
    pL2TPConfigData->dwAuthType = L2TP_IPSEC_AUTH_PRESHAREDKEY; 
    pL2TPConfigData->dwFlags = 0; 
    pL2TPConfigData->cbKey = cbKey; 
    pL2TPConfigData->dwOffsetKey = sizeof(L2TP_CONFIG_DATA); 
    pL2TPConfigData->cMyCerts = 0; 
    pL2TPConfigData->cRootCerts = 0; 
    pL2TPConfigData->dwOffsetCertHashes = sizeof(L2TP_CONFIG_DATA); 
    if (g_sharedKey) { 
        memcpy((PBYTE)pL2TPConfigData+pL2TPConfigData->dwOffsetKey, 
g_sharedKey, cbKey); 
    } 
    pConfigData = (PBYTE)pL2TPConfigData; 
    cbConfigData = sizeof(L2TP_CONFIG_DATA) + cbKey; 
} 


(...) 


// Create a new phone-book entry. 
res = ::RasSetEntryProperties(NULL, g_entryName, &rasEntry, sizeof 
(rasEntry), pConfigData, cbConfigData); 
if (res != 0) { 
    wprintf(L"Cannot create or update the phone book entry (error# %u). 
Aborting.", res); 
    goto exit; 
} 

In the code the Length (cbKey) of the key is determined but can someone explain to me where the actual key is in the code? Or can someone provide me an explaination on how to set a Pre Shared Key in RASEntry for L2TP?

Thank you so much

twickl

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:07:06+00:00Added an answer on May 31, 2026 at 1:07 pm

    The pre-shared key is copied into the L2TP_CONFIG_DATA structure with this line:

    memcpy((PBYTE)pL2TPConfigData+pL2TPConfigData->dwOffsetKey, g_sharedKey, cbKey);
    

    Basically this line says “copy the data from g_sharedKey into the pL2TPConfigData instance, starting at an offset of pL2TPConfigData->dwOffsetKey for a length of cbKey“

    The code wraps this in an if block, so if g_sharedKey is NULL, it doesn’t do this copy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't really get lambda expressions. While they've been around since the days of
UPDATED QUESTION: Ok, I am going to simplify my question since I don't really
Hi stackoverflow coders, I have an app (since the iPhone its really chic to
I have a couple of projects hosted on Codeplex. Since I didn't really have
I post this topic because I have a problem with my iPhone application since
So, I really don't want any nulls passed into my server, because it destroys
I have an older form that I really don't want to rewrite at this
Since it's really not possible to return a single embedded document (yet), what is
The key event is not listened by my Flex app. Since it is really
I haven't really looked into the new .NET stuff since 2.0, but I'm wondering

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.