我的web應用程序在我的機器上編譯並運行良好。然而,當我把它發佈到我的IIS6服務器,我得到了臭名昭著Object reference not set to an instance of an object.
以下堆棧跟蹤發佈我的asp.net web應用程序給出'對象引用未設置爲對象的實例'。
[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
的標記文件Utils.cs如下
_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();
它去,並抓住了用戶活躍目錄和安全信息。第66行是DirectoryEntry行。我不知道這裏發生了什麼,因爲它在本地運行正常。
任何幫助表示讚賞謝謝。
女巫是線** Utils.cs: 66 ** – Aristos
DirectoryEntry entry = result.GetDirectoryEntry(); – Matt
@你去@Matt,搜索返回爲空。 – Aristos