通达OA 同时使用域帐号和OA内置帐号登录系统 .

通达OA 同时使用域帐号和OA内置帐号登录系统 .

通达OA支持域帐号绑定登录验证,在启用域验证后,但如果用户的OA帐号和域帐号不相同时,难免在OA登录页面输入域帐号,这样系统就提示登录失败。


经过以下修改,即可达到 OA帐号 和 域帐号 同时登录使用。

1. 新增一个 domainlogih.php 放在webroot根目录下

[php]

  1. <?
  2. include_once( "inc/conn.php" );
  3. if ( $UNAME != "" )
  4. {
  5. global $connection;
  6. $query = "select USER_ID from USER_MAP where USER_ID='".$UNAME."'";
  7. $cursor1 = exequery( $connection, $query );
  8. if (!($ROW1 = mysql_fetch_array( $cursor1 )) )
  9. {
  10. include_once( "inc/td_core.php" );
  11. include_once( "inc/utility.php" );
  12. include_once( "inc/ldap/adLDAP.php" );
  13. $SYNC_CONFIG = get_sys_para( "DOMAIN_SYNC_CONFIG" );
  14. $SYNC_CONFIG = unserialize( $SYNC_CONFIG['DOMAIN_SYNC_CONFIG'] );
  15. $option = get_ldap_option( $SYNC_CONFIG );
  16. $adldap = new adLDAP( $option );
  17. if ( !$adldap->authenticate( $SYNC_CONFIG['AD_USER'], $SYNC_CONFIG['AD_PWD'] ) )
  18. {
  19. message( "", _( "モ犹リイホハノ靹テモミホ・" ).$adldap->get_last_error( ).")" );
  20. exit( );
  21. }
  22. $user_info = $adldap->user_info( $USER_GUID, array( "objectsid" ), FALSE );
  23. $user_info = $adldap->user_info( iconv( ini_get( "default_charset" ), "utf-8", $UNAME ), array( "objectguid" ) );
  24. if ( $user_info === FALSE )
  25. {
  26. message( "", _( "サ。モテサァ[".$DOMAIN_USER."]ミナマ「ウ・" ).$adldap->get_last_error( ).")" );
  27. exit( );
  28. }
  29. $user_info = $user_info[0];
  30. if ( is_array( $user_info ) || is_array( $user_info['objectguid'] ) || $user_info['objectguid'][0] != "" )
  31. {
  32. $USER_GUID = bin2guid( $user_info['objectguid'][0] );
  33. $query = "select USER_ID from USER_MAP where USER_GUID='".$USER_GUID."'";
  34. $cursor1 = exequery( $connection, $query );
  35. if ( $ROW1 = mysql_fetch_array( $cursor1 ) )
  36. {
  37. $UNAME = $ROW1['USER_ID'];
  38. }
  39. }
  40. }
  41. }
  42. include_once( "logincheck.php" );
  43. ?>
<?
include_once( "inc/conn.php" );

if ( $UNAME != "" )
{
	global $connection;
	$query = "select USER_ID from USER_MAP where USER_ID='".$UNAME."'";
	$cursor1 = exequery( $connection, $query );
	
	if (!($ROW1 = mysql_fetch_array( $cursor1 )) )
	{
		include_once( "inc/td_core.php" );
		include_once( "inc/utility.php" );
		include_once( "inc/ldap/adLDAP.php" );
		
		$SYNC_CONFIG = get_sys_para( "DOMAIN_SYNC_CONFIG" );
		$SYNC_CONFIG = unserialize( $SYNC_CONFIG['DOMAIN_SYNC_CONFIG'] );
		$option = get_ldap_option( $SYNC_CONFIG );
		$adldap = new adLDAP( $option );
		if ( !$adldap->authenticate( $SYNC_CONFIG['AD_USER'], $SYNC_CONFIG['AD_PWD'] ) )
		{
			message( "", _( "モ犹リイホハノ靹テモミホ・" ).$adldap->get_last_error( ).")" );
			exit( );
		}
		$user_info = $adldap->user_info( $USER_GUID, array( "objectsid" ), FALSE );
		$user_info = $adldap->user_info( iconv( ini_get( "default_charset" ), "utf-8", $UNAME ), array( "objectguid" ) );
		if ( $user_info === FALSE )
		{
			message( "", _( "サ。モテサァ[".$DOMAIN_USER."]ミナマ「ウ・" ).$adldap->get_last_error( ).")" );
			exit( );
		}
		$user_info = $user_info[0];
		if ( is_array( $user_info ) || is_array( $user_info['objectguid'] ) || $user_info['objectguid'][0] != "" )
		{
			$USER_GUID = bin2guid( $user_info['objectguid'][0] );
			$query = "select USER_ID from USER_MAP where USER_GUID='".$USER_GUID."'";
			$cursor1 = exequery( $connection, $query );
			if ( $ROW1 = mysql_fetch_array( $cursor1 ) )
			{
				$UNAME = $ROW1['USER_ID'];
			}
		}
	}
}
include_once( "logincheck.php" );
?>


2. 把 templates 目录下的子目录 index.html 文件的表单Action更改为 domainlogin.php (原来是logincheck.php)

[html]

  1. <form name="form1" method="post" action="domainlogin.php" {autocomplete} onsubmit="{form_submit}">
  2. <table cellspacing="0" cellpadding="0" align="center">
  3. <tr class="img_field">
  4. <td align="center">{logo_img}</td>
  5. </tr>
  6. <tr height="37" class="login_field">
  7. <td align="center">
  8. <b>用户名</b> <input type="text" class="text" name="UNAME" size="15" onmouseover="this.focus()" onfocus="this.select()" value="{username_cookie}">
  9. <b>密码</b> <input type="password" class="text" name="PASSWORD" onmouseover="this.focus()" onfocus="this.select()" size="15" value="">
  10. <input type="submit" name="submit" class="submit" value="登 录">
  11. </td>
  12. </tr>
  13. </table>
  14. <br>{usb_key_option}
  15. {usbkey_object}
  16. </form>
<form name="form1" method="post" action="domainlogin.php" {autocomplete} οnsubmit="{form_submit}">

  <table cellspacing="0" cellpadding="0" align="center">
    <tr class="img_field">
      <td align="center">{logo_img}</td>
    </tr>
    <tr height="37" class="login_field">
      <td align="center">
        <b>用户名</b> <input type="text" class="text" name="UNAME" size="15" οnmοuseοver="this.focus()" οnfοcus="this.select()" value="{username_cookie}">
        <b>密码</b> <input type="password" class="text" name="PASSWORD" οnmοuseοver="this.focus()" οnfοcus="this.select()" size="15" value="">
          <input type="submit" name="submit" class="submit" value="登 录">
      </td>
    </tr>
  </table>
  <br>{usb_key_option}
  {usbkey_object}
</form>


 templates下有多个子目录,都需要把 index.html按上述方面更改。


保存就可以实现无论使用域帐号还是OA的帐号,都可以登录系统。