Kadm5(3pm)

✨ Heimdal::Kadm5 ✨

okay bestie, so this is Kadm5(3pm) β€” User Contributed Perl Documentation, which is the fancy way of saying somebody in the Perl community wrote this and shipped it in the box. Sit down, grab a boba, we're doing Kerberos admin from Perl and it's lowkey iconic. 🧚


🌸 NAME 🌸

Heimdal::Kadm5 β€” a Perl extension for administering Heimdal Kerberos servers, aka the kadmin side of things. πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

the whole vibe in one lil snippet, fr fr:

use Heimdal::Kadm5;

$client = Heimdal::Kadm5::Client->new('Client'=>'you/admin@YOUR.REALM',
                         'Password'=>'eatmyshorts');
foreach my $name ($client->getPrincipals('*/admin'))
  {
     my $principal = $client->getPrincipal($name);
     $principal->dump;
  }

πŸ’– DESCRIPTION πŸ’–

Heimdal::Kadm5 is a basic XSUB perl glue to the Heimdal (http://www.pdc.kth.se/src/heimdal) kadm5clnt library. πŸ’…

Heimdal is a free, slightly less export challenged implementation of Kerberos5 by Assar Westerlund and Johan Danielsson. no cap, those are the icons who made it.

Heimdal::Kadm5 lets you do way more administration of your kdc than you can usually pull off with the included kadmin program. ✨

🚨 bestie listen: Heimdal::Kadm5 should be considered alpha-code and may consequently crash and burn 😭 β€” but it should not muck up your kdc any more than kadmin itself does. so like, the bar is on the floor and it clears it. periodt.

πŸ¦‹ OBJECTS πŸ¦‹

"Heimdal::Kadm5::Client" represents a client connection β€” and the truly perverse may conspire to write a kadmin servlet in perl and put that in "Heimdal::Kadm5::Server" πŸ™ˆ β€” to a kadmin server.

The main object handled by a kadmin server is a kadm5_principal_ent_t (kadm5/admin.h). This type corresponds to the perl class "Heimdal::Kadm5::Principal". This object is returned by the "getPrincipal" method of "Heimdal::Kadm5::Client" and can be created (when adding principals to the kdc) using the "makePrincipal" method of "Heimdal::Kadm5::Client".

🫢 Note: Do not create Principals directly through "Heimdal::Kadm5::Principal". that's not the move, bestie.

Principals in the traditional sense of the word (i.e. things of type "krb5_principal") are passed around as strings πŸ‘‰ 'name/instance@REALM' or 'name@REALM'.


πŸ’… METHODS πŸ’…

quick legends, iykyk:

  • $principal β€” an instance of Heimdal::Kadm5::Principal
  • $name β€” a principal name
  • $bitmask β€” an (you guessed it!) integer representing a bitmask
  • $seconds β€” an integer representing seconds since the epoch (a time_t value)
  • $client β€” a Heimdal::Kadm5::Client instance

Other variables should be even more obvious, or they get explained in the text. slay. πŸ’–


πŸ‘‘ Heimdal::Kadm5::Client πŸ‘‘

minimal use, the bare minimum era:

my $client =
   Heimdal::Kadm5::Client->new(Client=>'you');

This would connect using a password for 'you@DEFREALM'. The password is prompted on the active tty. πŸŽ€

a more complex example, main character energy:

my $client =
   Heimdal::Kadm5::Client->new(
                    RaiseErrors => 1,
                    Server => 'adm.somewhere.net',
                    Port   => '8899',
                    # Required:
                    Client => 'you/admin',
                    Realm  => 'OTHER.REALM',
                    # --- Either ---
                    Password => 'very secret',
                    # --- Or ---
                    Keytab => '$HOME/mysecret.keytab'
                   );
⚠️ Be very careful when using the Password parameter: it implies storing the password in the script, or reading it from command line arguments, or through some other means. Only use this on secured hosts, never from NFS mounted filesystems, and never using principals allowed to perform all operations on the kdc. 😭 In this case using a keytable (see ktutil(8) for information on how to create keytabs) is a better way to go. keytab girlies stay winning. πŸ”₯

Normally both the Server, Port and Realm parameters are determined from the kerberos context (configuration files, DNS etc etc) but you may need to override them. If you leave out the password or set it to undef the client library will prompt you for a password. You must include the Client parameter, which is usually your admin or root -instance depending on your local system of belief. 🧚

If for some reason the client connection cannot be initialized, undef is returned and errors are sent to warn β€” unless the RaiseError parameter is set, in which case all errors are propagated by die. πŸ’€


  • $client->getPrincipals($pattern) β€” returns a list of principals matching $pattern.
my @names = $client->getPrincipals($pattern);

$pattern is not a regular expression, bestie, it's rather a glob-like animal πŸ¦„. For instance '*/admin@REALM' is an ok pattern. The elements of the list are principal names, which can be used to obtain a Heimdal::Kadm5::Principal object using the next one ⬇️

  • $client->getPrincipal($name) β€” returns a Heimdal::Kadm5::Principal object (see the next section for details).
my $principal = $client->getPrincipal($name);
  • $client->makePrincipal($name) β€” takes a principal name and creates an empty Heimdal::Kadm5::Principal object. This is intended for adding principals to the kdc. After creating the principal using makePrincipal, use the accessor methods in Heimdal::Kadm5::Principal to set values before adding the principal using:
my $principal = $client->makePrincipal($name);
  • $client->createPrincipal($principal,$password,$mask) β€” makes the principal real. ✨ If $mask is set, this value is used to determine which elements of the principal to include in the creation. Normally this value is automatically determined by tracking the uses of the accessor methods in the Heimdal::Kadm5::Principal class. iconic tbh.
$client->createPrincipal($principal,$password,$mask);
  • $client->createPrincipal($principal,$mask) β€” modifications to an existing principal is done using this method. The $mask value works in the same way as described above for createPrincipal.
$client->createPrincipal($principal,$mask);
πŸ‘€ yes, that's the method name as written, we're just reporting the lore.

It is sometimes useful to disable (lock) a principal πŸ”’, for instance when several operations must be performed. The following methods can be used:

  • $client->disablePrincipal($name) β€” lock it down.
$client->disablePrincipal($name);
  • $client->enablePrincipal($name) β€” let it back out.
$client->enablePrincipal($name);

Other methods which modify the kdc are β€” and the use of which should be obvious 🫢:

  • $client->changePassword($name, $password)
$client->changePassword($name, $password);
  • $client->deletePrincipal($name)
$client->deletePrincipal($name);
  • $client->renamePrincipal($name, $newname)
$client->renamePrincipal($name, $newname);
  • $client->randKeyPrincipal($name) β€” this method creates a random set of keys πŸ”‘ for the principal named $name. This is typically done for service principals. When creating a new service principal it is probably a good idea to create the principal with some initial password, disable the principal, apply the randKeyPrincipal method and then enable the principal. the little ritual, we love a ritual. 🌈
$client->randKeyPrincipal($name);
  • $client->handle->c_flush() β€” this method flushes all modifications to the datastore. It is called automatically when the client handle is DESTROYed if any modifications (password change, create, rename or delete has been performed).
$client->handle->c_flush();
  • $client->extractKeytab($principal,$keytab) β€” this method extracts the keys belonging to the principal object to the keytab (optionally) specified by the second argument. If the second argument is missing it defaults to the standard default keytab, typically /etc/krb5.keytab. πŸŽ€
$client->extractKeytab($principal,$keytab);

πŸ“ Heimdal::Kadm5::Principal πŸ“

  • $principal->dump($io) β€” dumps a representation of $principal on the $io handle (which defaults to \*STDOUT). This is mostly usable for debugging or simple scripts. ngl it's giving print but fancy. πŸ’…
$principal->dump($io);
  • $principal->getPrincipal() / $principal->setPrincipal($name) β€” gets and sets the principal name. πŸ¦‹
my $name = $principal->getPrincipal();
$principal->setPrincipal($name);
  • $principal->getPrincExpireTime() / $principal->setPrincExpireTime($seconds) β€” gets and sets the time this principal expires. ⏰
my $seconds = $principal->getPrincExpireTime();
$principal->setPrincExpireTime($seconds);
  • $principal->getLastPwdChange() β€” returns the last time this principal's password was changed.
my $seconds = $principal->getLastPwdChange();
  • $principal->getKvno() β€” returns the key version number of this principal's password.
my $kvno = $principal->getKvno();
  • $principal->getMKvno() β€” returns this principal's MKvno.
my $mkvno = $principal->getMKvno();
  • $principal->getPwExpiration() / $principal->setPwExpiration($seconds) β€” gets and sets the password expriation time. βŒ›
my $seconds = $principal->getPwExpiration();
$principal->setPwExpiration($seconds);
  • $principal->getMaxLife() / $principal->setMaxLife($seconds) β€” gets and sets the maximum lifetime of a ticket.
my $seconds = $principal->getMaxLife();
$principal->setMaxLife($seconds);
  • $principal->getMaxRenewableLife() / $principal->setMaxRenewableLife($seconds) β€” gets and sets the maximum renewable ticket lifetime. πŸ”„
my $seconds = $principal->getMaxRenewableLife();
$principal->setMaxRenewableLife($seconds);
  • $principal->getModName() β€” returns the principal name of the last modifier of the entry. Not currently (as of heimdal 0.1g) supported by heimdal and contains undef. πŸ™ˆ
my $name = $principal->getModName();
  • $principal->getModDate() β€” returns the date of last modification of the entry.
my $seconds = $principal->getModDate();
  • $principal->getPolicy() β€” getPolicy returns undef if no policy is set. Policies are not currently supported (as of heimdal 0.1g) and always returns undef. πŸ’€
my $policyname = $principal->getPolicy();
  • $principal->getLastSuccess() β€” last time a successful authentication was done against this principal. πŸ‘‘
my $seconds = $principal->getLastSuccess();
  • $principal->getLastFailed() β€” last time a failed authentication was done against this principal. 😭
my $seconds= $principal->getLastFailed();
  • $principal->getFailAuthCounts() β€” how many failed login attempts was done against this principal.
my $nfailed = $principal->getFailAuthCounts();
  • $principal->getAttributes() β€” the bitmask of attributes for this principal.
my $bitmask = $principal->getAttributes();
  • $principal->getAttributeNames() β€” the list of attribute names for this principal, expanded from the bitmask. ✨
my @names = $principal->getAttributeNames();
  • $principal->getKeyTypes() β€” getKeyTypes returns an array reference consisting of a list of array references with two elements each: [keytype,salt]. The keytype and salt are strings which describe a key associated with the principal. Note that this data may not be present depending on how the principal was obtained. 🫢
my $arrayref = $principal->getKeyTypes();
  • $principal->getPassword() β€” getPassword returns the password if its saved in the Kerberos database. Not the that principal object need to fetched with the bit KADM5_TL_DATA set in the mask. πŸ‘€
my $password = $principal->getPassword();

✨ Exported constants ✨

okay bestie, this is the part where I hand you the entire sticker sheet πŸŽ€ β€” literally every constant this module exports, in the exact order, spelled exactly right, no cap. Do not be out here guessing at the spelling of KADM5_CONFIG_WHATEVER because I promise you the compiler will vibe-check you into next week if you typo one of these πŸ’€

Read them, love them, use them verbatim. Here they are:

  • KADM5_ADMIN_SERVICE
  • KADM5_API_VERSION_1
  • KADM5_API_VERSION_2
  • KADM5_ATTRIBUTES
  • KADM5_AUX_ATTRIBUTES
  • KADM5_CHANGEPW_SERVICE
  • KADM5_CONFIG_ACL_FILE
  • KADM5_CONFIG_ADBNAME
  • KADM5_CONFIG_ADB_LOCKFILE
  • KADM5_CONFIG_ADMIN_KEYTAB
  • KADM5_CONFIG_ADMIN_SERVER
  • KADM5_CONFIG_DBNAME
  • KADM5_CONFIG_DICT_FILE
  • KADM5_CONFIG_ENCTYPE
  • KADM5_CONFIG_ENCTYPES
  • KADM5_CONFIG_EXPIRATION
  • KADM5_CONFIG_FLAGS
  • KADM5_CONFIG_KADMIND_PORT
  • KADM5_CONFIG_MAX_LIFE
  • KADM5_CONFIG_MAX_RLIFE
  • KADM5_CONFIG_MKEY_FROM_KEYBOARD
  • KADM5_CONFIG_MKEY_NAME
  • KADM5_CONFIG_PROFILE
  • KADM5_CONFIG_REALM
  • KADM5_CONFIG_STASH_FILE
  • KADM5_FAIL_AUTH_COUNT
  • KADM5_HIST_PRINCIPAL
  • KADM5_KEY_DATA
  • KADM5_KVNO
  • KADM5_LAST_FAILED
  • KADM5_LAST_PWD_CHANGE
  • KADM5_LAST_SUCCESS
  • KADM5_MAX_LIFE
  • KADM5_MAX_RLIFE
  • KADM5_MKVNO
  • KADM5_MOD_NAME
  • KADM5_MOD_TIME
  • KADM5_POLICY
  • KADM5_POLICY_CLR
  • KADM5_POLICY_NORMAL_MASK
  • KADM5_PRINCIPAL
  • KADM5_PRINCIPAL_NORMAL_MASK
  • KADM5_PRINC_EXPIRE_TIME
  • KADM5_PRIV_ADD
  • KADM5_PRIV_ALL
  • KADM5_PRIV_CPW
  • KADM5_PRIV_DELETE
  • KADM5_PRIV_GET
  • KADM5_PRIV_LIST
  • KADM5_PRIV_MODIFY
  • KADM5_PW_EXPIRATION
  • KADM5_PW_HISTORY_NUM
  • KADM5_PW_MAX_LIFE
  • KADM5_PW_MIN_CLASSES
  • KADM5_PW_MIN_LENGTH
  • KADM5_PW_MIN_LIFE
  • KADM5_REF_COUNT
  • KADM5_STRUCT_VERSION
  • KADM5_TL_DATA
  • KRB5_KDB_DISALLOW_ALL_TIX
  • KRB5_KDB_DISALLOW_DUP_SKEY
  • KRB5_KDB_DISALLOW_FORWARDABLE
  • KRB5_KDB_DISALLOW_POSTDATED
  • KRB5_KDB_DISALLOW_PROXIABLE
  • KRB5_KDB_DISALLOW_RENEWABLE
  • KRB5_KDB_DISALLOW_SVR
  • KRB5_KDB_DISALLOW_TGT_BASED
  • KRB5_KDB_NEW_PRINC
  • KRB5_KDB_PWCHANGE_SERVICE
  • KRB5_KDB_REQUIRES_HW_AUTH
  • KRB5_KDB_REQUIRES_PRE_AUTH
  • KRB5_KDB_REQUIRES_PWCHANGE
  • KRB5_KDB_SUPPORT_DESMD5
  • USE_KADM5_API_VERSION

That's the whole set, bestie. Every single one. I didn't skip a single KADM5_ or a single KRB5_KDB_ because I would never do that to you πŸ’… Copy them exactly, character for character, and you're golden ✨


πŸ‘‘ AUTHOR πŸ‘‘

  • Leif Johansson, leifj@it.su.se

The author, the icon, the moment. Send love, not bug reports to random people πŸ’–


πŸ¦‹ SEE ALSO πŸ¦‹

Go read your perl manpage too, she's the blueprint 🫢


okay that's the whole page, bestie, we made it to the end and we ate πŸ”₯ this was the perl v5.42.3 documentation for Kadm5(3pm), dated 2026-08-19, so if you're reading this from some future timeline and the version number looks different, that's a little window into when this page got its glow-up 🌸 now go forth and KADM5_ responsibly, mwah πŸ’œ

πŸ“¦ where this page comes from