-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPOCKerberosObjects.php
81 lines (49 loc) · 1.83 KB
/
POCKerberosObjects.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
// create a principal
// primary php binding to kerb
// $conn = new KADM5("HTTP/[email protected]", "/etc/apache2/krb5.keytab", true);
// this object is used by the kerberos object to actually create the princ
// $princ = new KADM5Principal('testlala');
// $princ->setExpiryTime(2342342);
/*
$princ = $conn->getPrincipal('testlala');
echo "<pre>";
var_dump($princ);
var_dump($princ->getPropertyArray());
echo "</pre>";
echo "<br/><br/><br/>";
// change principal's password
// primary object "nameOfPrincipal", "location of key", usingAKey (t/f)
$conn = new KADM5("HTTP/[email protected]", "/etc/apache2/krb5.keytab", true);
// fetch principal in question
$princ = $conn->getPrincipal('testlala');
//change principal's password
$princ->changePassword('footest');
echo "CHANGED PASSWORD";
echo "<pre>";
var_dump($princ);
var_dump($princ->getPropertyArray());
echo "</pre>";
// acquire a ticket for the principal
$ticket = new KRB5CCache();
$ticket->initPassword('testlala', 'footest');
echo "<pre>";
var_dump($ticket->getEntries());
echo "</pre>";
*/
// ok now with objects. This emulates the initial creation of a principal.
require_once("User.php");
$newEmail = "[email protected]";
$newNonce = null; // null is an excepted value for nonce
$newUserId = 372021;
$user = new KerberosUsers($newEmail, $newNonce, $newUserId);
// kerberos object
$conn = new KADM5("HTTP/[email protected]", "/etc/apache2/krb5.keytab", true);
$princName = "webUser" . $user->getUserId() . "/[email protected]";
$princ = new KADM5Principal($princName);
// create the princ
$createdPrinc = $conn->createPrincipal($princ, 'testpass');
echo "<pre>";
var_dump($createdPrinc);
echo "</pre>";
?>