my $client =
This would connect using a password for you@DEFREALM. The password is
prompted on the active tty.
A more complex example:
my $client =
RaiseErrors => 1,
Server => adm.somewhere.net,
Port => 8899,
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 commmand line arguments or through some other means. Only use
this on secured hosts, never from NFS mounted filesystems, and <B>neverB> 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.
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.
my @names = $client->getPrincipals($pattern);
The getPrincipals method returns a list of principals matching $pattern which is not a
regular expression but 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
Heimdal::Kadm5::Principal object using
my $principal = $client->getPrincipal($name);
which returns a Heimdal::Kadm5::Principal object (see the next section for details).
my $principal = $client->makePrincipal($name);
The makePrincipal method 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
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.
Modifications to an existing principal is done using this method:
The $mask value works in the same way as described above for createPrincipal. It is sometimes
useful to disable (lock) a principal, for instance when several operations must be performed.
The following methods can be used:
Other methods which modify the kdc are and the use of which should be obvious:
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.
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);
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.
Dumps a representation of $principal on the $io handle (which defaults to \*STDOUT).
This is mostly usable for debugging or simple scripts.
my $name = $principal->getPrincipal();
Gets and sets the principal name.
my $seconds = $principal->getPrincExpireTime();
Gets and sets the time this principal expires.
my $seconds = $principal->getLastPwdChange();
Returns the last time this principals password was changed.
my $kvno = $principal->getKvno();
Returns the key version number of this principals password.
my $mkvno = $principal->getMKvno();
Returns this principals MKvno.
my $seconds = $principal->getPwExpiration();
Gets and sets the password expriation time.
my $seconds = $principal->getMaxLife();
Gets and sets the maximum lifetime of a ticket.
my $seconds = $principal->getMaxRenewableLife();
Gets and sets the maximum renewable ticket lifetime.
my $name = $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 $seconds = $principal->getModDate();
Returns the date of last modification of the entry.
my $policyname = $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 $seconds = $principal->getLastSuccess();
Last time a successful authentication was done against this principal.
my $seconds= $principal->getLastFailed();
Last time a failed authentication was done against this principal.
my $nfailed = $principal->getFailAuthCounts();
How many failed login attempts was done against this principal.
my $bitmask = $principal->getAttributes();
The bitmask of attributes for this principal.
my @names = $principal->getAttributeNames();
The list of attribute names for this principal, expanded from the bitmask.
my $arrayref = $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
my $password = $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.