虽然我不迷信,但是老天看起来对我还不错

今天终于解决了最后一个issue,一个困扰了我好几天的issue,一个看起来不怎么样,但是却很恶心的issue。一个本以为很easy,但是却费了大劲,其实又很简单的issue,一个真想大骂一声TMD的issue,终于给我在睡觉前搞定了。为了这两个issue,这周末都没休息上,还搭上了一个周一。总结一下这两天来的工作成果,一个是有关于Exchange服务器上的issue,一个是关于EXT-GWT在IE8下界面的issue.

先说一下有关于Exchange服务器上的issue,

问题:

在Exchange2010的server上,对文件的操作权限是需要域用户的权限的。这样就导致了一个问题,当一个进程被windows服务启动起来的时候,会因为权限不足而导致失败。我们都知道windows服务的默认权限是system用户,一个比administrator具有更高权限的账户,但是它却不能在Exchange2010的server上创建文件。

解决:

或许可以通过配置域的policy来解决,但是那样会导致其他的一些问题,增加域中policy的复杂度。或者用域帐户来启动service,也许可行,但是同样会有一些问题,比如与其他system进程的交互等。所以比较合理的解决方案就是将启动的进程用CreateProcessAsUser或是CreateProcessWithLogonW的API来创建,这两个API都是根据提供的用户信息来启动用户session的进程。主要的区别就是使用CreateProcessAsUser前需要先LogonUser。说到LogonUser,不得不说一下

BOOL LogonUser( __in LPTSTR lpszUsername, __in_opt LPTSTR lpszDomain, __in LPTSTR lpszPassword, __in DWORD dwLogonType, __in DWORD dwLogonProvider, __out PHANDLE phToken);

第四个参数dwLogonType的含义, msdn上是这么介绍的:

The type of logon operation to perform. This parameter can be one of the following values, defined in Winbase.h.

Value Meaning

LOGON32_LOGON_BATCH

This logon type is intended for batch servers, where processes may be executing on behalf of a user without their direct intervention. This type is also for higher performance servers that process many plaintext authentication attempts at a time, such as mail or web servers. The LogonUser function does not cache credentials for this logon type.

这个参数适合于批处理,也就是没有界面,只做后台运算的进程

LOGON32_LOGON_INTERACTIVE

This logon type is intended for users who will be interactively using the computer, such as a user being logged on by a terminal server, remote shell, or similar process. This logon type has the additional expense of caching logon information for disconnected operations; therefore, it is inappropriate for some client/server applications, such as a mail server.

这个参数适合于界面的进程,如果你的service要和界面交互的话,必须用这个

LOGON32_LOGON_NETWORK

This logon type is intended for high performance servers to authenticate plaintext passwords. The LogonUser function does not cache credentials for this logon type.

LOGON32_LOGON_NETWORK_CLEARTEXT

This logon type preserves the name and password in the authentication package, which allows the server to make connections to other network servers while impersonating the client. A server can accept plaintext credentials from a client, call LogonUser, verify that the user can access the system across the network, and still communicate with other servers.

LOGON32_LOGON_NEW_CREDENTIALS

This logon type allows the caller to clone its current token and specify new credentials for outbound connections. The new logon session has the same local identifier but uses different credentials for other network connections.

This logon type is supported only by the LOGON32_PROVIDER_WINNT50 logon provider.

这个需要window2003以上的系统支持

LOGON32_LOGON_SERVICE

Indicates a service-type logon. The account provided must have the service privilege enabled.

这个参数适合于创建一个service

LOGON32_LOGON_UNLOCK

This logon type is for GINA DLLs that log on users who will be interactively using the computer. This logon type can generate a unique audit record that shows when the workstation was unlocked.

 

所以你想创建一个特定用户session的进程,这个参数需要注意。另外,记住要调用DuplicateTokenEx函数把logon的Token给复制一份,否则你会改变当前进程的Token设置。

同时强调一下,对DLL的接口参数千万不要用C++标准库里的类型来传递,比如std::string作为传递字符的容器。否则,就是一个死,死都不知道怎么死。原因,一是C++库是非多线程安全的,这就意味这当你的DLL函数被用作多线程中,数据很可能会被莫名其妙的修改掉;二是,C++的对象析构发生的比较晚,当你卸载掉DLL模块后,如果这时再发生对原来模块里面的C++对象析构操作,那就是一个死,进程保准Crash掉。

 

第二个issue,

问题:

EXT-GWT创建的ComboBox,当元素个数超过30个后,并且被嵌套了多层的LayerContainer的情况下,在IE8里就无法弹出下拉列表。这实际上是一个EXT-GWT的一个Bug,但是为了解决这个Bug,花费了我2天的时间。试尽了各种办法,都无效。最搞笑的是,我自己手写了一个列表,在点击ComboBox时来弹出,都没有效果。基本上,可以说这应该是一个LayerContainer嵌套的bug。通过跟踪发现,在这种情况下的列表视图的Height属性都为0。我猜测是因为动态生成时通过计算当前Table的高度来求列表视图的高度而出的问题。

解决:

引用2.20版本的gxt.jar来解决。

原文链接: https://www.cnblogs.com/moonz-wu/archive/2010/10/26/1860912.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    虽然我不迷信,但是老天看起来对我还不错

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/16590

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月7日 下午4:57
下一篇 2023年2月7日 下午4:57

相关推荐