r/PHPhelp • • Aug 31 '22

When to use LDAP?

Hey everyone,

My buddy and I are working on a project, he's more of an IT solutions guy and I'm a programmer/designer. The app we're building has a user registration system and the app also enables them to upload files. We would like to host the application on our own servers, that's where his role comes into play.

He came back to me suggesting we utilize Active Directory or LDAP whereas I already started building everything in MySql. After digging into Active Directory/LDAP, I must admit that it seems like a nice package but is it secure, safe & supported? Are these technologies better served in certain environments than others? Are thee any advantages for using LDAP overa SQL database to manage user credentials/authentication in addition to storing files? If we use LDAP for those things, would I be better off writing the entirety of my DB schema in LDAP or does a hybrid with MySql make sense?

Appreciate any insight - I'm a hobbyist PHP dev who works professionally in other languages so some of these more nuanced topics aren't as familiar to me.

Thanks!

7 Upvotes

8 comments sorted by

6

u/gordonv Aug 31 '22

So, there are actually 3 technologies you should be looking at:

  • Active Directory (Windows Login via Domain)

  • LDAP (The open Lightweight Directory Protocol for unsimilar systems to authenticate)

  • SSO (Single Sign On) (Authenticating with other big providers like Google, Facebook, AWS, Etc)

So when do you use what?

  • AD, Active Directory, if you're in an office environment and everyone logs into a domain. The Domain server is local to your network. And you want to integrate app permissions into the windows administrator's view. This is more secure, but requires the client to be connected to the business network.

  • LDAP, this is easy and is used for basic authentication. You can't embed permission levels like how you can with AD. Also, you need to be on the local network. In PHP, most people use LDAP to access their AD hosted logins. You have to login to the page manually. And your sessions can be sustained by cookies.

  • Single Sign On, SSO. This is where a web resource can authenticate with a workplace server from where ever. Best of all, it creates the illusion of a web page being magically logged in via your Windows sign on. Also, for extra security, you can bundle MFA.

I recommend using SSO. This removes that "immersion breaking" moment when users need to log in with a username and password, because windows in the background is logging you in. But for that to happen, you need to install an SSO software on your Primary Domain Controller, a windows server.

Also, many services are getting into using something like PingID with SSO+AD to create that "enter your pin that you just got on your phone" security system.

1

u/concernedesigner Sep 01 '22

Wow thanks a bunch for the detailed response, sounds like I need to dig deeper to get a better full picture here. SSO sounds like a great solution for authentication, and I also have experience with it in the workplace daily, so I totally see the benefits. I think my buddy just kinda really confused me and perhaps this doesn't even relate to what the project is actually aiming to do. This is not a business or private solution we're developing; it will be public facing.

2

u/gordonv Sep 01 '22

it will be public facing.

Oh. Hands down. SSO. I don't know what kind of host you are using. AWS has a service called Cognito that does this and works with AWS.

miniOrange, PingIDentity, and Okta are popular solutions. Sticker shock, you will be paying around $500+ a year for the service. But, these services take the responsibility of secure authentication on a higher level. Good enough for the general public.

I think Google has a free offering, but, you want something that allows multiple options.

1

u/concernedesigner Sep 01 '22

ha I was actually just on Okta's site! I think it makes sense to shift that responsibility, I don't mind not being the gatekeeper lol.

I will say, having dabbled in Web3 and blockchain, using wallets to authenticate users is such a nice and easy way to accomplish almost the same exact thing. Not to get all crypto-y here but wallet connections/authentication is the one thing I love about the tech.

2

u/gordonv Aug 31 '22

So, there's another kind of system that might get mentioned, but isn't used in web pages. This is called an AAA server. Authenticate, Authorize, Access. This is usually called a RADIUS server. This is mainly used in Wireless. Today, these link up with AD.

In the Windows world, AD is the king. Everything else cowtows to it. LDAP, AAA, and SSO.

For PHP, don't use AAA or Radius.

2

u/gordonv Aug 31 '22

Deduplicating access via LDAP is a good idea. Less stuff to admin. The users will remember their username and password is the same as their "Windows Power On" password.

And if you have to lock down the account, easy to do it in one step.

1

u/projector_man Sep 01 '22

I use LDAP in one of my apps user accounts, works great in my context. So much less admin for managing user accounts.

You will still want to use mysql for a number of reasons.

  1. Logging

  2. At least one admin account that isn't tied to the LDAP, incase that goes down.

  3. Setting permissions, my environment is a school. Teachers are allowed in, students are not, some teachers are allowed into certain parts of the app, others are not. All managed through my accounts table

0

u/[deleted] Sep 01 '22

[deleted]

1

u/concernedesigner Sep 01 '22

For a public website site, I can think of no reason to add the complexity of LDAP or Active Directory. SSO is a different matter, but not essential either

Thanks, yeah I think you're exactly right. I think I jumped the gun when my buddy made the suggestions and I just kinda spiraled into these topics lol. The searching functionality in ldap seems like a nice benefit but if I track my user's uploads on the database I also have access to querying searches.