First comment on this, I think you will get more/better results on a PostgreSQL form than a SQL Server forum. That being said, PostgreSQL has documentation on authentication. Have you reviewed this already?
Link in case you were unaware - https://www.postgresql.org/docs/current/auth-methods.html
As for which approach you use, it really depends on the requirements. Active Directory supports LDAP, but it really depends on your environment and configuration and requirements. If simple LDAP lookup against AD is acceptable, then you can use that. If you want it a bit more secure, then GSSAPI is a better approach.
If you are looking for examples, those are provided in the official documentation. I would recommend that you start with the official documentation than random people on the internet. Plus there is a lot of internal setup that needs to be in place too such as firewall rules.
The above is all just my opinion on what you should do.
As with all advice you find on a random internet forum - you shouldn't blindly follow it. Always test on a test server to see if there is negative side effects before making changes to live!
I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.