Skip to content

Commit

Permalink
Read birthday from AD attribute "info"
Browse files Browse the repository at this point in the history
  • Loading branch information
pfzim committed Jun 25, 2022
1 parent 90ea1b0 commit b5b6ee2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ define('APP_LANGUAGE', 'ru');

## Изменения в новых версиях

**25.06.2022**
- День рождения считывается из атрибута info регулярным выражением. Формат: `BIRTHDAY: DD.MM.YYYY`. Пример: `BIRTHDAY: 25.01.1978`

**10.10.2020**
- Параметры LDAP_HOST и LDAP_PORT заменены на LDAP_URI. Пример: `ldaps://dc-01 ldap://dc-02:389`
- При обнолении пароли у учётных записей будут заменены на 'admin', т.к. функция PASSWORD больше не поддерживается MySQL. Их требуется сменить.
Expand Down
19 changes: 16 additions & 3 deletions routes/contacts_sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function contacts_sync(&$core, $params, $post_data)
$core->LDAP->get_link(),
LDAP_BASE_DN,
PB_LDAP_FILTER,
['objectguid', 'samaccountname' , 'sn', 'initials', 'middleName', 'givenname', 'mail', 'department', 'company', 'title', 'telephonenumber', 'mobile', 'thumbnailphoto', 'useraccountcontrol'],
['objectguid', 'samaccountname' , 'sn', 'initials', 'middleName', 'givenname', 'mail', 'department', 'company', 'title', 'telephonenumber', 'mobile', 'thumbnailphoto', 'useraccountcontrol', 'info'],
0,
0,
0,
Expand All @@ -43,7 +43,7 @@ function contacts_sync(&$core, $params, $post_data)
$referrals = NULL;
$errcode = NULL;
$errmsg = NULL;

if(!ldap_parse_result($core->LDAP->get_link(), $result, $errcode , $matcheddn , $errmsg , $referrals, $controls))
{
throw new Exception('ldap_parse_result return error code: '.$errcode.', message: '.$errmsg.', ldap_error: '.ldap_error($core->LDAP->get_link()));
Expand All @@ -66,7 +66,7 @@ function contacts_sync(&$core, $params, $post_data)

// *********************************************************

$v_flags = 0;
$v_flags = 0;
$v_adid = bin2hex(@$entries[$i]['objectguid'][0]); // unique active directory id
$v_samaccountname = @$entries[$i]['samaccountname'][0];
$v_first_name = @$entries[$i]['givenname'][0];
Expand All @@ -80,7 +80,20 @@ function contacts_sync(&$core, $params, $post_data)
$v_phone_mobile = @$entries[$i]['mobile'][0];
$v_mail = @$entries[$i]['mail'][0];
$v_type = 0;

$v_birthday = 'NULL'; // raw value
if(!empty($entries[$i]['info'][0]) && preg_match('/BIRTHDAY: (\d{2})\.(\d{2})\.(\d{4})/', $entries[$i]['info'][0], $match))
{
$nd = intval($match[1]);
$nm = intval($match[2]);
$ny = intval($match[3]);

if(datecheck($nd, $nm, $ny))
{
$v_birthday = sprintf('\'%04d-%02d-%02d\'', $ny, $nm, $nd);
}
}

$v_reserved1 = '';
$v_reserved2 = '';
$v_reserved3 = '';
Expand Down

0 comments on commit b5b6ee2

Please sign in to comment.