Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Ldap Auth

Ldap Auth

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++visual-studiohelptutorial
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ika2
    wrote on last edited by
    #1

    Hi, I'm developing a tool to show several graphs. But only the users that have been succesfully authentificated by LDAP should see those graphs. I'm developing with MFC+Visual Studio 2003. I'm not really sure how to do this. I've been reading for a while about LDAP but I'm not sure how to implement authentification by LDAP in my App. This is just a test I have done doing copy&paste from other code, but it always returns err=0x31. LDAP* ld = NULL; INT iRtn = 0; INT connectSuccess = 0; PCHAR pHost = NULL; PCHAR userDN = NULL; PCHAR pw = NULL; ULONG version = LDAP_VERSION3; // SecPkgContext_ConnectionInfo sslInfo; LONG lv = 0; CString strDomain; CString strName; CString strPass; // Verify that the user passed a hostname. GetDlgItem(IDC_DOMAIN)->GetWindowText(strDomain); GetDlgItem(IDC_PASSWORD)->GetWindowText(strPass); GetDlgItem(IDC_NAME)->GetWindowText(strName); CString dn = "CN=" + strName +",DM=" + strDomain; // Create an LDAP session. ld = ldap_open(pHost,0); if (ld == NULL) GetDlgItem(IDC_EDIT4)->SetWindowText("ldap_open failed"); else { GetDlgItem(IDC_EDIT4)->SetWindowText("ldap_open OK"); ld->ld_lberoptions = 0; pw = new char [strPass.GetLength()+1]; strcpy (pw,(LPCTSTR)strPass); userDN = new char [dn.GetLength()+1]; strcpy (userDN,(LPCTSTR)dn); INT err = ldap_simple_bind_s( ld, userDN, pw ); CString error; error.Format("%d", err); GetDlgItem(IDC_EDIT4)->SetWindowText("simple bind returned " + error); } if (ld != NULL) ldap_unbind_s(ld); if(pHost!=NULL) delete pHost; if(userDN != NULL) delete userDN; if(pw != NULL) delete pw; Regards and sorry for my poor english

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups