Skip to content

Instantly share code, notes, and snippets.

@pmeulen
Created July 19, 2015 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmeulen/1109444223c729c022ca to your computer and use it in GitHub Desktop.
Save pmeulen/1109444223c729c022ca to your computer and use it in GitHub Desktop.
Generate user accounts for SimpleSAMLphp example-userpass
<?php
/*
$config: php config array
$group: account name prefix
$email: A pollibly existing email addres so you can receive mail
$scope: Used as schachome, EPPN scope and names
$count: number of accounts to generate
Example:
account_gen($config, 'pieter-a', 'pieter@surfnet.nl', 'institution-a.nl', 5);
account_gen($config, 'pieter-b', 'pieter@surfnet.nl', 'institution-b.nl', 5);
account_gen($config, 'pieter-c', 'pieter@surfnet.nl', 'institution-c.nl', 5);
Creates accounts with u/p:
pieter-a1, pieter-a2, ...
pieter-b1, pieter-b2, ...
pieter-c1, pieter-c2, ...
*/
function account_gen(&$config, $prefix, $email, $scope, $count)
{
for($i=1;$i<=$count;$i++)
{
$uid=$prefix.$i;
$account=array(
'uid' => array($uid),
'eduPersonPrincipalName' => $uid.'@'.$scope,
'givenName' => 'G-'.$uid,
'sn' => 'S-'.$scope,
'cn' => $uid.' '.$scope,
'mail' => str_replace('@', '+'.$uid.'-'.$scope.'@', $email),
'displayName' => 'D-'.$uid.' '.$scope,
'eduPersonAffiliation' => array('student'),
'schacHomeOrganization' => $scope,
'schacHomeOrganizationType' => 'urn:mace:terena.org:schac:homeOrganizationType:int:university',
);
$config['example-userpass'][$uid.':'.$uid]=$account;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment