一个奇怪的问题
今天遇到一個奇怪的問題,在這里登記一下,備查。版本Dynamics AX2009 RU7
為了限定用戶多次登錄系統,在info類的startupPost方法里寫了一段代碼:
void?restrictLoginTwice(){
????//?To?restrict?user?login?form?second?login
????xSession?session;
????SysClientSessions?SysClientSessions;
????UserId?currentUserId;
????int?counter;
????;
????currentUserId?=?curUserId();
????if(currentUserId!="Admin")//?Allow?Admin?User?to?login?multiple?time
????{
?????????while?select?SysClientSessions
?????????where?SysClientSessions.userId?==?currentUserId?&&
?????????SysClientSessions.Status?==?1?//?1?:?Login?0?:?Logout
?????????{
?????????????session?=?new?xSession(SysClientSessions.SessionId,?true);
?????????????if?(session?&&?session.userId())
????????????????counter++;
?????????}
?????}
?????if(counter>=2)
?????{????????????
????????????infolog.shutDown(true);
?????}
}
在實際使用的過程中發現,這段代碼對某些用戶組可以限定只能登錄一次,但某些用戶組這段代碼好像失效了,可以多次登錄。
經過反復測試發現,如果用戶組沒有如下圖所示的權限,運行這段代碼查詢表SysClientSessions的時候就會出現異常,直接跳過。
下面的四個窗體不需要賦權限,只需要選中每日這個節點給予權限。
如果沒有給予權限,在查詢SysClientSessions表的時候就會出現異常,并且不會給任何異常信息。
這個問題很容易重現,選一個用戶組,沒有管理->每日的權限,寫一個job查詢表SysClientSessions表,就會出現異常了。
所以要正確查詢SysclientSessions,需要有這個權限。
至于為什么,不曉得。
轉載于:https://www.cnblogs.com/Farseer1215/archive/2012/09/11/2679619.html
總結
- 上一篇: 让表单文本框只读不可编辑的方法
- 下一篇: halcon--1D measuring