本文整理汇总了PHP中adLDAP::user_info方法的典型用法代码示例。如果您正苦于以下问题:PHP adLDAP::user_info方法的具体用法?PHP adLDAP::user_info怎么用?PHP adLDAP::user_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类adLDAP
的用法示例。
在下文中一共展示了adLDAP::user_info方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeSignin
public function executeSignin($request)
{
$this->form = new sfGuardFormSignin();
if ($request->isMethod('post')) {
$data = $request->getParameter('signin');
$adldap = new adLDAP(array('account_suffix' => '@sch.bme.hu', 'domain_controllers' => array('152.66.208.42'), 'ad_username' => $data['username'], 'ad_password' => $data['password']));
try {
$authUser = $adldap->authenticate($data['username'], $data['password']);
if ($authUser === true) {
$userData = $adldap->user_info($data['username']);
$user = Doctrine::getTable('sfGuardUser')->findOneBy('username', $data['username']);
$save = false;
if ($user) {
if ($user->Profile->full_name != $userData[0]["displayname"][0] || $user->Profile->email != $userData[0]["mail"][0]) {
$save = true;
}
} else {
$user = new sfGuardUser();
$save = true;
}
if ($save) {
$user->username = $data['username'];
$user->password = $data['password'];
$user->Profile->full_name = $userData[0]["displayname"][0];
$user->Profile->email = $userData[0]["mail"][0];
$user->save();
}
}
} catch (Exception $e) {
echo $e;
}
}
parent::executeSignin($request);
}
示例2: TestPDC
function TestPDC()
{
global $SAMSConf;
$info = array();
$lang = "./lang/lang.{$SAMSConf->LANG}";
require $lang;
if (isset($_GET["auth"])) {
$auth = $_GET["auth"];
}
print "<H1>TEST PDC</H1>";
$value = ExecuteShellScript("getwbinfousers", "{$SAMSConf->WBINFOPATH}");
$a = explode(" ", $value);
sort($a);
$acount = count($a);
if ($auth == "ntlm") {
for ($i = 0; $i < $acount; $i++) {
print "{$a[$i]}<BR>\n";
}
}
if ($auth == "adld") {
require_once "adldap.php";
//create the LDAP connection
$pdc = array("{$SAMSConf->LDAPSERVER}");
$options = array(account_suffix => "@{$SAMSConf->LDAPDOMAIN}", base_dn => "{$SAMSConf->LDAPBASEDN}", domain_controllers => $pdc, ad_username => "{$SAMSConf->LDAPUSER}", ad_password => "{$SAMSConf->LDAPUSERPASSWD}", "", "", "");
$ldap = new adLDAP($options);
$groups = $ldap->all_groups($include_desc = false, $search = "*", $sorted = true);
$gcount = count($groups);
print "<TABLE CLASS=samstable>";
print "<TH width=5%>No";
print "<TH >{$SAMSConf->LDAPDOMAIN} groups";
for ($i = 0; $i < $gcount; $i++) {
echo "<TR><TD>{$i}:<TD>{$groups[$i]}<BR>";
}
echo "</TABLE><P>";
$users = $ldap->all_users($include_desc = false, $search = "*", $sorted = true);
$count = count($users);
print "<TABLE CLASS=samstable>";
print "<TH width=5%>No";
print "<TH >{$SAMSConf->LDAPDOMAIN} users";
for ($i = 0; $i < $count; $i++) {
$userinfo = $ldap->user_info($users[$i], $fields = NULL);
//$mcount=count($userinfo);
echo "<TR><TD>{$i}:<TD> {$users[$i]} ";
$aaa = $userinfo[0]["displayname"][0];
//$aaa2 = $userinfo[0]["givenname"][0];
//$aaa3 = $userinfo[0]["sn"][0];
echo "<TD>{$aaa} ";
}
echo "</TABLE>";
}
}
示例3: array
var_dump($result);
}
// create a user account
if (0) {
$attributes = array("username" => "freds", "logon_name" => "freds@mydomain.local", "firstname" => "Fred", "surname" => "Smith", "company" => "My Company", "department" => "My Department", "email" => "freds@mydomain.local", "container" => array("Container Parent", "Container Child"), "enabled" => 1, "password" => "Password123");
$result = $ldap->user_create($attributes);
var_dump($result);
}
// retrieve the group membership for a user
if (0) {
$result = $ldap->user_groups("username");
print_r($result);
}
// retrieve information about a user
if (0) {
$result = $ldap->user_info("username");
print_r($result);
}
// check if a user is a member of a group
if (0) {
$result = $ldap->user_ingroup("username", "Group Name");
var_dump($result);
}
// modify a user account (this example will set "user must change password at next logon")
if (0) {
$attributes = array("change_password" => 1);
$result = $ldap->user_modify("username", $attributes);
var_dump($result);
}
// change the password of a user
if (0) {
示例4: foreach
$adUsers = $adldap->all_users();
foreach ($adUsers as $adUser) {
// loop over all the Active Directory users
// skip the excluded usernames
$skip = 0;
foreach ($excludedUsers as $ex) {
if ($ex == $adUser) {
$skip = 1;
break;
}
}
if ($skip == 1) {
continue;
}
// query LDAP for the full user info
$userInfo = $adldap->user_info($adUser, $ldapAttributes);
if (NewUser($adUser, $oemrUsers)) {
// add new user
echo "Adding user {$adUser}";
if (AddUser($adUser, $userInfo)) {
echo ", OK\n";
} else {
echo ", FAILED\n";
}
} else {
// update existing users with Active Directory info
echo "existing user {$adUser}";
if (UpdateUser($adUser, $userInfo)) {
echo ", OK\n";
} else {
echo ", FAILED\n";
示例5: AddUsersFromAdLDAP
function AddUsersFromAdLDAP()
{
require_once "adldap.php";
global $SAMSConf;
global $USERConf;
$DB = new SAMSDB();
$lang = "./lang/lang.{$SAMSConf->LANG}";
require $lang;
if ($USERConf->ToWebInterfaceAccess("UC") != 1) {
exit(0);
}
if (isset($_GET["domainname"])) {
$domainname = $_GET["domainname"];
}
if (isset($_GET["username"])) {
$userlist = $_GET["username"];
}
if (isset($_GET["groupname"])) {
$usergroup = $_GET["groupname"];
}
if (isset($_GET["usershablon"])) {
$usershablon = $_GET["usershablon"];
}
if (isset($_GET["enabled"])) {
$enabled = $_GET["enabled"];
}
if (isset($_GET["domain"])) {
$domain = $_GET["domain"];
}
if (isset($_GET["newgroupname"])) {
$newgroupname = $_GET["newgroupname"];
}
if ($enabled == "on") {
$enabled = 1;
} else {
$enabled = -1;
}
if (strlen($domainname) > 1) {
$domain = $domainname;
}
$i = 0;
$adldserver = GetAuthParameter("adld", "adldserver");
$basedn = GetAuthParameter("adld", "basedn");
$adadmin = GetAuthParameter("adld", "adadmin");
$adadminpasswd = GetAuthParameter("adld", "adadminpasswd");
$adldusergroup = GetAuthParameter("adld", "usergroup");
$LDAPBASEDN2 = strtok($basedn, ".");
$LDAPBASEDN = "DC={$LDAPBASEDN2}";
while (strlen($LDAPBASEDN2) > 0) {
$LDAPBASEDN2 = strtok(".");
if (strlen($LDAPBASEDN2) > 0) {
$LDAPBASEDN = "{$LDAPBASEDN},DC={$LDAPBASEDN2}";
}
}
$pdc = array("{$adldserver}");
$options = array(account_suffix => "@{$basedn}", base_dn => "{$LDAPBASEDN}", domain_controllers => $pdc, ad_username => "{$adadmin}", ad_password => "{$adadminpasswd}", "", "", "");
$ldap = new adLDAP($options);
if ($usergroup == -1) {
$QUERY = "SELECT s_group_id FROM sgroup where s_name = '{$newgroupname}'";
$result = $DB->samsdb_query_value($QUERY);
if ($result == 0) {
$result = $DB->samsdb_query("INSERT INTO sgroup (s_name) VALUES('{$newgroupname}') ");
$QUERY = "SELECT s_group_id FROM sgroup where s_name = '{$newgroupname}'";
$result = $DB->samsdb_query_value($QUERY);
}
$row = $DB->samsdb_fetch_array();
$usergroup = $row['s_group_id'];
}
$query = "select s_quote from shablon where s_shablon_id='{$usershablon}'";
$num_rows = $DB->samsdb_query_value($query);
$row = $DB->samsdb_fetch_array();
$s_quote = $row['s_quote'];
$DB->free_samsdb_query();
while (strlen($userlist[$i]) > 0) {
$string = $userlist[$i];
$i++;
$user = "{$string}";
$username = UTF8ToSAMSLang($user);
$num_rows = $DB->samsdb_query_value("SELECT * FROM squiduser WHERE s_nick='{$user}'");
if ($num_rows == 0) {
$userinfo = $ldap->user_info($user, $fields = NULL);
$givenname = $userinfo[0]["givenname"][0];
$sn = $userinfo[0]["sn"][0];
$QUERY = "INSERT INTO squiduser (s_group_id, s_shablon_id, s_nick, s_domain, s_enabled, s_quote, s_family, s_name) VALUES('{$usergroup}', '{$usershablon}', '{$username}', '{$domain}', '{$enabled}', '{$s_quote}', '{$sn}', '{$givenname}')";
$num_rows = $DB->samsdb_query($QUERY);
}
}
print "<SCRIPT>\n";
print " parent.lframe.location.href=\"lframe.php\"; \n";
print " parent.tray.location.href = \"tray.php?show=exe&function=authadldtray&filename=authadldtray.php\"; \n";
print "</SCRIPT> \n";
}