私のWebアプリケーションはコンパイルされ、自分のマシンで正常に動作します。しかし私のasp.net Webアプリケーションを公開すると、 'オブジェクト参照がオブジェクトのインスタンスに設定されていません。'というメッセージが表示されます。
_UserName = windowsId.Name.Substring(windowsId.Name.IndexOf('\\') + 1);
_DomainName = windowsId.Name.ToString().Remove(windowsId.Name.IndexOf('\\'));
//Get users information from active directory
DirectorySearcher search = new DirectorySearcher("LDAP://DCHS");
search.Filter = String.Format("(SAMAccountName={0})", _UserName);
SearchResult result = search.FindOne();
DirectoryEntry entry = result.GetDirectoryEntry();
_FullName = result.Properties["givenName"][0].ToString() + ' ' + result.Properties["sn"][0].ToString();
_Email = result.Properties["mail"][0].ToString();
_FirstName = result.Properties["givenName"][0].ToString();
_SSID = windowsId.User.ToString();
を次のように私はIIS6サーバーに公開するとき、私は次のスタックトレース
[NullReferenceException: Object reference not set to an instance of an object.]
ForYourInformation.LDAPDetails..ctor(IntPtr logonToken) in d:\documents\documents\visual studio 2010\Projects\ForYourInformation\ForYourInformation\Utils.cs:66
ForYourInformation._Default.Page_Load(Object sender, EventArgs e) in d:\documents\documents\visual studio 2010\Projects\ForYourInformation\ForYourInformation\Default.aspx.cs:24
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +24
System.Web.UI.Control.LoadRecursive() +70
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3047
で悪名高いObject reference not set to an instance of an object.
を取得フラグが付けられたファイルUtils.csそれは、ユーザーがアクティブになるとグラブですディレクトリとセキュリティ情報。 66行目はDirectoryEntry行です。私はここで何が起こっているのか分からない。
ご協力いただきありがとうございます。
魔女ライン** Utils.csです:プロジェクト\ ForYourInformation \ ForYourInformation \ Utils.cs \ Visual Studioの2010 \ドキュメント\ \ドキュメント66 ** – Aristos
DirectoryEntryエントリ= result.GetDirectoryEntry(); – Matt
@あなたが@Mattに行くと、検索からの戻り値はnullです。 – Aristos