I am using Google's method for connecting my Mac fleet to Google's LDAPs service using these instructions:
Connect LDAP clients to the Secure LDAP service
Everyting works great when I run the Python script from the terminal but when I generate a .app file using py2app for deployment, I get eDSNodeNotFound. I am using localhost for the node. From what I read, apparently apps do not have access to localhost. I've some mentions of using the hostname or IP address with user authentication but those credentials are passed in clear text and I'm not willing to take that chance. We have around 500 Macs to deploy this to. I am using Python3 on MacOS 14.41. Py2App is version 0.28 (the latest). I do not want to install the Python framework on my Mac fleet for security reasons.
Here is the exact error:
/Users/Shared/dcsd_ldap/dist/ldap_python_config.app/Contents/MacOS/ldap_python_config ; exit;
<main> attribute status: eDSNodeNotFound
<dscl_cmd> DS Error: -14008 (eDSNodeNotFound)
The script is as follows (Works from terminal - fails from py2app application execution)
Follow the steps below to connect the macOS client for user account authentication using the Secure LDAP service.
The instructions in this section focus on how to manually set up and test macOS authentication using the Secure LDAP service.
For instructions, see Add LDAP clients, or watch this Secure LDAP demo. You will also download an auto-generated TLS client certificate during this process.
Convert the key and cert into a PKCS 12 (p12) file. Run the following command in the terminal:
openssl pkcs12 -export -out ldap-client.p12 -in ldap-client.crt -inkey ldap-client.key
Tip: Write down the name of the .p12 file.
The system will ask you to enter a password. Enter a password with which to encrypt the p12 file.
Open the Keychain Access application.
Click on the System keychain.
Click File > Import Items.
Select the ldap-client.p12 file created above.
If prompted, enter the admin password to allow modification of the system keychain.
Enter the password you created above to decrypt the .p12 file.
Note: Expect to see a new cert and associated private key show up in the list of keys. It may be called LDAP Client. Write down the cert’s name for the next step below.Add a line to the /etc/openldap/ldap.conf file, ensuring that "LDAP Client" is exactly the same certificate name as shown in the macOS Keychain Access application after importing the .p12 file (the name comes from the X.509 Subject Common Name of the generated certificate):
sudo bash -c 'echo -e "TLS_IDENTITY\tLDAP Client" >> /etc/openldap/ldap.conf'
Open the Directory Utility application to create a new LDAP directory node:
Any Google Workspace or Cloud Identity user can log in using a network account (Google account) using their username and password. This login process needs network connectivity. If a user needs to log in with or without connection to the network, a mobile account can be created. A mobile account lets you use your network account (Google account) username and password to sign in, whether or not you’re connected to the network. For more details, see Create and configure mobile accounts on Mac.
To create a mobile account for Secure LDAP users:
Run the following command to connect to the Secure LDAP server and set up a home path and mobile account(s):
sudo /System/Library/CoreServices/ManagedClient.app/Contents/Resources/createmobileaccount -n $uid -v
Tip: Replace $uid with the username part of the email address associated with the user’s Google account. For example, jsmith is the username part for jsmith@solarmora.com.
When prompted for the SecureToken admin user name, enter your admin username, and enter your password in the next prompt. This will add $uid into the FileVault. This is needed if the macOS disk is encrypted.
The instructions in this section focus on automating the device configuration for your users. Perform steps 1 and 2 below on the same macOS device where you completed your manual configuration during the preparation phase.
In this step, you are extracting all the manual configurations that you completed during step 3 of the preparation phase into a XML file. You can use this file and the Mac profile created in step 1 above to automatically configure other macOS devices.
Copy the python script below and save it as a python file (.py file).
Note: This sample script is provided on an as-is basis. Google support will not provide support for sample scripts.
Here is the line in the following script that fails. The localhost nodename is what is failing (I believe).
os.system("dscl -q localhost -append /Search CSPSearchPath /LDAPv3/ldap.google.com")
The full script is below:
Ldap_pythong_config.py
#!/usr/bin/python
from OpenDirectory import ODNode, ODSession, kODNodeTypeConfigure
from Foundation import NSMutableData, NSData
import os
import sys
# Reading plist
GOOGLELDAPCONFIGFILE = open(sys.argv[1], "r")
CONFIG = GOOGLELDAPCONFIGFILE.read()
GOOGLELDAPCONFIGFILE.close()
# Write the plist
od_session = ODSession.defaultSession()
od_conf_node, err = ODNode.nodeWithSession_type_error_(od_session, kODNodeTypeConfigure, None)
request = NSMutableData.dataWithBytes_length_(b'\x00'*32, 32)
request.appendData_(NSData.dataWithBytes_length_(CONFIG, len(CONFIG)))
response, err = od_conf_node.customCall_sendData_error_(99991, request, None)
# Edit the default search path and append the new node to allow for login
os.system("dscl -q localhost -append /Search CSPSearchPath /LDAPv3/ldap.google.com")
os.system("bash -c 'echo -e \"TLS_IDENTITY\tLDAP Client\" >> /etc/openldap/ldap.conf' ")
Thank you for any help! I am super frustrated.
Greg
I can't even get this far when I try to run the terminal commands to disable digest-md5 etc I get a operation not allowed error (even after allowing full disk access for terminal). The LDAPv3 folder is locked down in Sonoma 14.5. Does anyone know how to disable these services in Sonoma?
I faced the same problem in Sonoma, too.
I googled a bit and find a solution.
<URL removed by staff>
I executed following command, it seems that ldap.google.com.plist file was updated correctly.
sudo odutil set configuration /LDAPv3/ldap.google.com module ldap option "Denied SASL Methods" CRAM-MD5 DIGEST-MD5 NTLM GSSAPI
Apples Python is broken.
Use this solution: https://www.googlecloudcommunity.com/gc/Workspace-Q-A/secure-LDAP-on-macos/m-p/773356#M20270