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::Kadm5should be considered alpha-code and may consequently crash and burn π β but it should not muck up your kdc any more thankadminitself 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 ofHeimdal::Kadm5::Principal$nameβ a principal name$bitmaskβ an (you guessed it!) integer representing a bitmask$secondsβ an integer representing seconds since the epoch (atime_tvalue)$clientβ aHeimdal::Kadm5::Clientinstance
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 thePasswordparameter: 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 (seektutil(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 aHeimdal::Kadm5::Principalobject (see the next section for details).
my $principal = $client->getPrincipal($name);
$client->makePrincipal($name)β takes a principal name and creates an emptyHeimdal::Kadm5::Principalobject. This is intended for adding principals to the kdc. After creating the principal usingmakePrincipal, use the accessor methods inHeimdal::Kadm5::Principalto set values before adding the principal using:
my $principal = $client->makePrincipal($name);
$client->createPrincipal($principal,$password,$mask)β makes the principal real. β¨ If$maskis 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 theHeimdal::Kadm5::Principalclass. iconic tbh.
$client->createPrincipal($principal,$password,$mask);
$client->createPrincipal($principal,$mask)β modifications to an existing principal is done using this method. The$maskvalue works in the same way as described above forcreatePrincipal.
$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 therandKeyPrincipalmethod 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 isDESTROYed 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$principalon the$iohandle (which defaults to\*STDOUT). This is mostly usable for debugging or simple scripts. ngl it's givingprintbut 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'sMKvno.
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 containsundef. π
my $name = $principal->getModName();
$principal->getModDate()β returns the date of last modification of the entry.
my $seconds = $principal->getModDate();
$principal->getPolicy()βgetPolicyreturnsundefif no policy is set. Policies are not currently supported (as of heimdal 0.1g) and always returnsundef. π
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()βgetKeyTypesreturns an array reference consisting of a list of array references with two elements each:[keytype,salt]. Thekeytypeandsaltare 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()βgetPasswordreturns the password if its saved in the Kerberos database. Not the that principal object need to fetched with the bitKADM5_TL_DATAset 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_SERVICEKADM5_API_VERSION_1KADM5_API_VERSION_2KADM5_ATTRIBUTESKADM5_AUX_ATTRIBUTESKADM5_CHANGEPW_SERVICEKADM5_CONFIG_ACL_FILEKADM5_CONFIG_ADBNAMEKADM5_CONFIG_ADB_LOCKFILEKADM5_CONFIG_ADMIN_KEYTABKADM5_CONFIG_ADMIN_SERVERKADM5_CONFIG_DBNAMEKADM5_CONFIG_DICT_FILEKADM5_CONFIG_ENCTYPEKADM5_CONFIG_ENCTYPESKADM5_CONFIG_EXPIRATIONKADM5_CONFIG_FLAGSKADM5_CONFIG_KADMIND_PORTKADM5_CONFIG_MAX_LIFEKADM5_CONFIG_MAX_RLIFEKADM5_CONFIG_MKEY_FROM_KEYBOARDKADM5_CONFIG_MKEY_NAMEKADM5_CONFIG_PROFILEKADM5_CONFIG_REALMKADM5_CONFIG_STASH_FILEKADM5_FAIL_AUTH_COUNTKADM5_HIST_PRINCIPALKADM5_KEY_DATAKADM5_KVNOKADM5_LAST_FAILEDKADM5_LAST_PWD_CHANGEKADM5_LAST_SUCCESSKADM5_MAX_LIFEKADM5_MAX_RLIFEKADM5_MKVNOKADM5_MOD_NAMEKADM5_MOD_TIMEKADM5_POLICYKADM5_POLICY_CLRKADM5_POLICY_NORMAL_MASKKADM5_PRINCIPALKADM5_PRINCIPAL_NORMAL_MASKKADM5_PRINC_EXPIRE_TIMEKADM5_PRIV_ADDKADM5_PRIV_ALLKADM5_PRIV_CPWKADM5_PRIV_DELETEKADM5_PRIV_GETKADM5_PRIV_LISTKADM5_PRIV_MODIFYKADM5_PW_EXPIRATIONKADM5_PW_HISTORY_NUMKADM5_PW_MAX_LIFEKADM5_PW_MIN_CLASSESKADM5_PW_MIN_LENGTHKADM5_PW_MIN_LIFEKADM5_REF_COUNTKADM5_STRUCT_VERSIONKADM5_TL_DATAKRB5_KDB_DISALLOW_ALL_TIXKRB5_KDB_DISALLOW_DUP_SKEYKRB5_KDB_DISALLOW_FORWARDABLEKRB5_KDB_DISALLOW_POSTDATEDKRB5_KDB_DISALLOW_PROXIABLEKRB5_KDB_DISALLOW_RENEWABLEKRB5_KDB_DISALLOW_SVRKRB5_KDB_DISALLOW_TGT_BASEDKRB5_KDB_NEW_PRINCKRB5_KDB_PWCHANGE_SERVICEKRB5_KDB_REQUIRES_HW_AUTHKRB5_KDB_REQUIRES_PRE_AUTHKRB5_KDB_REQUIRES_PWCHANGEKRB5_KDB_SUPPORT_DESMD5USE_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
- ubuntu stonking: libheimdal-kadm5-perl 0.08-6build6 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms