1+ <?php
2+
3+ /*
4+ Generate accounts for simpleSAMLphp "example-userpass" auth source
5+
6+ $config: simplesaml php config array
7+ $prefix: account name prefix
8+ $email: An existing email address, if you want to receive mail
9+ $scope: Used as schachome, EPPN scope and names
10+ $slugs: array of account variants
11+ */
12+
13+ function account_gen (&$ config , $ prefix , $ email , $ scope , $ slugs )
14+ {
15+ foreach ($ slugs as $ slug )
16+ {
17+ $ uid =$ prefix .$ slug ;
18+ $ account =array (
19+ 'NameID ' => 'urn:collab:person: ' .$ scope .': ' .$ uid ,
20+ 'uid ' => array ($ uid ),
21+ 'eduPersonPrincipalName ' => $ uid .'@ ' .$ scope ,
22+ 'givenName ' => 'gn- ' .$ uid ,
23+ 'sn ' => 'sn- ' .$ scope ,
24+ 'cn ' => $ uid .' ' .$ scope ,
25+ 'mail ' => str_replace ('@ ' , '+ ' .$ uid .'@ ' , $ email ),
26+ 'displayName ' => 'd- ' .$ uid .' ' .$ scope ,
27+ 'eduPersonAffiliation ' => array ('student ' ),
28+ 'schacHomeOrganization ' => $ scope ,
29+ 'schacHomeOrganizationType ' => 'urn:mace:terena.org:schac:homeOrganizationType:int:university ' ,
30+ );
31+ $ config ['example-userpass ' ][$ uid .': ' .$ uid ]=$ account ;
32+ }
33+
34+ // Without SHO
35+ $ uid =$ prefix .'-nosho ' ;
36+ $ account =array (
37+ 'NameID ' => 'urn:collab:person: ' .$ scope .': ' .$ uid ,
38+ 'uid ' => array ($ uid ),
39+ 'eduPersonPrincipalName ' => $ uid .'@ ' .$ scope ,
40+ 'givenName ' => 'gn- ' .$ uid ,
41+ 'sn ' => 'sn- ' .$ scope ,
42+ 'cn ' => $ uid .' ' .$ scope ,
43+ 'mail ' => str_replace ('@ ' , '+ ' .$ uid .'@ ' , $ email ),
44+ 'displayName ' => 'd- ' .$ uid .' ' .$ scope ,
45+ 'eduPersonAffiliation ' => array ('student ' ),
46+ //'schacHomeOrganization' => $scope,
47+ 'schacHomeOrganizationType ' => 'urn:mace:terena.org:schac:homeOrganizationType:int:university ' ,
48+ );
49+ $ config ['example-userpass ' ][$ uid .': ' .$ uid ]=$ account ;
50+
51+ // Without mail
52+ $ uid =$ prefix .'-nomail ' ;
53+ $ account =array (
54+ 'NameID ' => 'urn:collab:person: ' .$ scope .': ' .$ uid ,
55+ 'uid ' => array ($ uid ),
56+ 'eduPersonPrincipalName ' => $ uid .'@ ' .$ scope ,
57+ 'givenName ' => 'gn- ' .$ uid ,
58+ 'sn ' => 'sn- ' .$ scope ,
59+ 'cn ' => $ uid .' ' .$ scope ,
60+ //'mail' => str_replace('@', '+'.$uid.'@', $email),
61+ 'displayName ' => 'd- ' .$ uid .' ' .$ scope ,
62+ 'eduPersonAffiliation ' => array ('student ' ),
63+ 'schacHomeOrganization ' => $ scope ,
64+ 'schacHomeOrganizationType ' => 'urn:mace:terena.org:schac:homeOrganizationType:int:university ' ,
65+ );
66+ $ config ['example-userpass ' ][$ uid .': ' .$ uid ]=$ account ;
67+
68+ // Without cn
69+ $ uid =$ prefix .'-nocn ' ;
70+ $ account =array (
71+ 'NameID ' => 'urn:collab:person: ' .$ scope .': ' .$ uid ,
72+ 'uid ' => array ($ uid ),
73+ 'eduPersonPrincipalName ' => $ uid .'@ ' .$ scope ,
74+ 'givenName ' => 'gn- ' .$ uid ,
75+ 'sn ' => 'sn- ' .$ scope ,
76+ //'cn' => $uid.' '.$scope,
77+ 'mail ' => str_replace ('@ ' , '+ ' .$ uid .'@ ' , $ email ),
78+ 'displayName ' => 'd- ' .$ uid .' ' .$ scope ,
79+ 'eduPersonAffiliation ' => array ('student ' ),
80+ 'schacHomeOrganization ' => $ scope ,
81+ 'schacHomeOrganizationType ' => 'urn:mace:terena.org:schac:homeOrganizationType:int:university ' ,
82+ );
83+ $ config ['example-userpass ' ][$ uid .': ' .$ uid ]=$ account ;
84+
85+ }
0 commit comments