- - PR -
ある処理が起動中に、別処理を別PCで起動すると画面が真っ白になる
1
投稿者 | 投稿内容 |
---|---|
|
投稿日時: 2007-05-14 00:11
今現在、現地でのテストができない状態にあるため、
有識者の方にこの現象がどういう原因で起きるのかご教授ください。 <環境> 言語:C#(WEBアプリ) OS:2003SERVER <現象> あるユーザーをActiveDirectoryに登録する処理(以降、「AD登録処理」)を起動中に、 別PCでWEBアプリ画面をあげリンクまたはボタン等をクリックすると 真っ白な画面のまま処理が止まってしまう現象が発生しました。 <他現象> ・AD登録処理を単独で起動すると正常に終了します。 ・AD登録処理が起動していない時に、別処理起動は正常に行われる。 <原因推測> @ユーザーをActiveDirectoryに登録する。 その際ソース中に「ユーザー偽装」をし、 処理を行っています。ユーザー偽装に問題がある?? Aソースをリビルド時にデバックモードで コンパイル??それが原因?? <偽装のソース> public class Impersonate : IDisposable { private static int LOGON32_LOGON_INTERACTIVE = 2; private static int LOGON32_PROVIDER_DEFAULT = 0; private WindowsImpersonationContext impersonationContext; [DllImport("advapi32.dll", SetLastError=true)] private static extern bool LogonUser( string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken ); [DllImport("advapi32.dll", SetLastError=true)] private extern static bool DuplicateToken( IntPtr ExistingTokenHandle, int SECURITY_IMPERSONATION_LEVEL, ref IntPtr DuplicateTokenHandle ); [DllImport("advapi32.dll", SetLastError=true)] private static extern bool RevertToSelf(); [DllImport("kernel32.dll", SetLastError=true)] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool CloseHandle(IntPtr hObject); private Impersonate(WindowsIdentity tempWindowsIdentity) { impersonationContext = tempWindowsIdentity.Impersonate(); } // 本体 public static Impersonate ImpersonateValidUser( string userName, string domain, string password) { WindowsIdentity tempWindowsIdentity; IntPtr token = IntPtr.Zero; IntPtr tokenDuplicate = IntPtr.Zero; Impersonate retValue = null; try { if (RevertToSelf()/* != 0*/) { if (LogonUser(userName, domain, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref token)/* != 0*/) { if (DuplicateToken(token, 2, ref tokenDuplicate)/* != 0*/) { tempWindowsIdentity = new WindowsIdentity(tokenDuplicate); retValue = new Impersonate(tempWindowsIdentity); if (retValue.impersonationContext == null) { retValue = null; } } } } return retValue; } finally { if (!(tokenDuplicate.Equals(IntPtr.Zero))) { CloseHandle(tokenDuplicate); } if (!(token.Equals(IntPtr.Zero))) { CloseHandle(token); } } } public virtual void Dispose() { if (!((impersonationContext) == null)) { impersonationContext.Undo(); impersonationContext = null; } } } |
|
投稿日時: 2007-05-14 07:14
どこかで見たことのあるコードやなぁ
現地で確認できないのはもっともとして、今いるところ(会社)で現地と似た環境は作れないのでしょうか?しょうもないことで問い合わせがあるかもしれず、その都度現地に出向くのは馬鹿らしいので、作っておくといいと思います。 その上で、どこで止まっているのか、ADの処理が終われば継続するのか、など、調べられることはまだあると思います。 _________________ |
1