Learn how to fix add_principal: invalid argument while creating error with our step-by-step troubleshooting guide for Kerberos.
If you’ve ever faced the frustrating error message add_principal: invalid argument while creating… you know the sinking feeling that comes when your carefully typed Kerberos command suddenly fails without a clear reason. Trust me, I’ve been there… staring at my terminal, wondering if I had misspelled something or worse, if I had broken my entire Kerberos setup. After hours of digging, testing and consulting logs, much like the process you’d go through for HTTP/0.9 error fixes… I finally unraveled the mystery and today I’m sharing a complete guide so you can troubleshoot and fix this error efficiently.
TL;DR – What This Error Really Means
Let’s start with the big picture. When you see add_principal: invalid argument while creating… it’s not a simple syntax issue in most cases. The message is generic and the real cause usually lives deeper in the Kerberos KDC or if you’re using an LDAP-backed KDB (like FreeIPA or 389-ds)… inside the LDAP server logs.
Here’s the quick version:
- The error occurs because the KDC rejects your principal creation request.
- Common culprits: ACL permissions… LDAP schema constraints… missing or mismatched policies… malformed principal names… or encryption type issues.
- Checking kadmind logs and LDAP logs usually reveals the exact reason.
- Using kadmin.local can help determine if ACLs are causing the problem.
By the end of this article, you’ll understand the root causes, know exactly where to look and have step-by-step commands to fix this issue.
Why This Error Happens (The Simple Version)
At first glance… add_principal: invalid argument while creating feels like your fault. Maybe you typed the wrong hostname or forgot the realm. But in reality, the error is usually server-side. The KDC receives your request, evaluates it and rejects it based on internal rules. If you’re using an LDAP backend… The LDAP server enforces schema rules, uniqueness and attribute constraints. All of this combines to produce the frustratingly vague message.
Think of it like trying to get into an exclusive club: you might meet the doorman perfectly dressed and ready… but if your invitation doesn’t meet their internal validation rules … VIP list mismatch… missing credentials… or wrong format … they won’t let you in. That “no entry” message is exactly what the Invalid argument is.
Most Common Root Causes
Let’s break it down in a structured way so you know exactly where to start:
1. ACL Permission Problems
One of the most frequent causes is insufficient privileges. The difference between kadmin.local and remote kadmin is critical here. kadmin.local talks directly to the KDB… bypassing ACL checks. If creating a principal works locally but fails remotely… your ACLs are probably misconfigured.
Example Fix: Check /etc/krb5kdc/kadm5.acl and ensure your admin principal has the create right:
*/admin@EXAMPLE.COM *
2. LDAP-Backed KDB Constraints
If your KDC uses LDAP (FreeIPA… 389-ds… or OpenLDAP)… schema and structural rules may prevent principal creation. Duplicate attributes… invalid container DNs… or required fields can trigger add_principal: invalid argument while creating.
For FreeIPA users… it’s often better to use ipa service-add or ipa user-add because the system maintains additional attributes that kadmin doesn’t manage directly.
3. Policy Requirements
Sometimes… a principal cannot be created because it violates a password or policy rule. For instance… if you specify a policy that doesn’t exist or your password doesn’t meet complexity requirements… the KDC may reject the request.
Tip: Create the policy first or assign an existing one during principal creation.
4. Malformed Principal Names
Kerberos is picky about principal formats. Hostnames… IP addresses… or special characters can trip it up. For example:
- host/192.168.1.6 may fail in certain LDAP setups.
- Spaces or unescaped special characters in the principal name can also cause failure.
Try creating a simple test principal first to rule this out:
kadmin: addprinc test-debug
5. Encryption Type and Key Tuple Issues
Older KDC versions or certain LDAP plugins can reject specific encryption types or key/salt tuples. If you’re specifying -e with unsupported encryption types… the KDC might respond with add_principal: invalid argument while creating.
Workaround: Use default encryption or explicitly specify a supported type:
addprinc -e aes256-cts-hmac-sha1-96 user1
6. Cross-Realm Principals
If you’re creating krbtgt/OTHERREALM@YOURREALM… special schema or attribute requirements may apply. FreeIPA and 389-ds often enforce stricter rules for trust principals.
Step-by-Step Diagnostics
Here’s the roadmap I use when this error appears. Copy and run these commands to quickly identify the root cause:
- Test with kadmin.local:
sudo kadmin.local
addprinc test-debug
- If it works locally but not remotely → ACL problem.
- Check KDC logs:
sudo journalctl -u kadmind -n 200
sudo grep -i “kadm5_create_principal” /var/log/*krb*
- Look for detailed KADM5 error codes.
- Check LDAP logs (if applicable):
- OpenLDAP or FreeIPA may report numeric result codes like 19 (constraintViolation) or 50 (insufficientAccessRights).
- Reproduce with a minimal principal:
- Helps isolate if the error is name or flag specific.
- Optional: Use kdb5_ldap_util for LDAP-specific tests.
- Advanced: Capture LDAP traffic between kadmind and LDAP server to inspect the exact response.
Mapping LDAP Error Codes to Fixes
If your KDC uses LDAP… these numeric codes are your roadmap:
| LDAP Code | Meaning | How to Fix |
|---|---|---|
| 19 | Constraint Violation | Check duplicates… objectClass… and required attributes. |
| 20 | Attribute Exists | Remove or rename duplicates. |
| 21 | Invalid Syntax | Correct principal format or special characters. |
| 50 | Insufficient Access | Adjust LDAP ACLs for the bind DN. |
| 53 | Unwilling to Perform | Check policy restrictions or structural rules. |
Advanced Cases and Rare Causes
- FreeIPA often rejects kadmin operations on certain principals because it manages extra attributes internally.
- Encryption type mismatches may silently fail. Try default or supported enctypes.
- DN generation bugs in older LDAP plugins can block creation. Updating your KDC packages may resolve the issue.
- For cross-realm trust principals… vendor-recommended creation tools are required.
Decision Tree – Quick Reference
Sometimes a simple visual helps more than paragraphs:
Does kadmin.local work?
├─ Yes → ACL problem → Fix kadm5.acl
└─ No → Check kadmind log
├─ Shows LDAP error → Check slapd logs
│ ├─ result=19 → Duplicate / constraint
│ ├─ result=21 → Syntax error
│ ├─ result=50 → Insufficient rights
│ └─ result=53 → Server policy restriction
└─ No LDAP error → KDB/plugin bug or invalid flags
Personal Anecdote
I remember once creating a principal for a Hadoop cluster … everything seemed correct… but I kept hitting add_principal: invalid argument while creating. I spent hours double-checking the hostname… realm… and command syntax. Finally… after diving into kadmind logs… I realized the FreeIPA schema prevented the creation due to a missing objectClass attribute. Adding the attribute and retrying made it work instantly. That’s when I realized: this error is rarely your fault; it’s usually the server enforcing its rules.
Example Debug Session
Here’s a quick real-world example:
sudo kadmin.local -q “addprinc test-debug”
# Works locally
kadmin -p admin/admin
addprinc host/192.168.1.6
# Fails
# Check kadmind log:
sudo grep -i “kadm5_create_principal” /var/log/kadmind.log
# Shows LDAP constraint violation
# Fix: correct DN in LDAP… then retry
kadmin -p admin/admin
addprinc host/192.168.1.6
# Success!
Key Takings:
Encountering add_principal: invalid argument while creating can feel like hitting a wall… but now you have a clear roadmap. Remember:
- Start with kadmin.local to isolate ACL issues.
- Inspect kadmind and LDAP logs for real errors.
- Test minimal principals to isolate naming or flags.
- Use policy… encryption… and FreeIPA-specific fixes where necessary.
- By following these steps… you’ll not only fix the immediate problem but also gain confidence in troubleshooting Kerberos issues in the future.
- Remember… I’ve been in your shoes … staring at the terminal… frustrated and unsure.
- Once you understand how the server interprets your requests… add_principal: invalid argument while creating becomes just another solvable puzzle rather than an impossible wall.
Additional Resources:
- MIT Kerberos Admin Guide: Comprehensive guide for Kerberos administrators. Covers kadmin, principal management, policies, and common errors like “Invalid argument while creating”.
- Red Hat Bugzilla #1035494: Details a specific occurrence of the add_principal error in Red Hat environments. Useful for troubleshooting cross-realm and trust-related issues.














