使用 Active Directory 组的网站间歇性缓慢地爬行
我在内网上有一个 ASP.NET MVC 网站。对站点的访问由活动目录中的组确定。有 4 个不同的组,每个组在站点中具有不同的访问权限。我偶尔会遇到网站运行缓慢的问题。该网站将正常运行几天,然后突然慢得像爬行一样。我有一个测试站点和一个生产站点。当速度下降时,两个站点都会受到同样的影响。我还有一个测试没有活动目录访问权限的网站,并且在这两个网站爬网时运行没有问题。我遇到问题的网站是在用户帐户下运行的,因为应用程序必须连接到 Intranet 上的另一个共享才能打印和合并 pdf 文件。这些站点在同一应用程序池下运行。当问题发生时,所有页面都同样慢,甚至没有数据库活动的页面也是如此。当问题发生时,我重置 IIS、重新启动网站并回收线程。真正解决问题的唯一方法是重新启动服务器。有时需要重新启动才能使站点恢复正常。以下是我尝试过的一些事情。看起来这个问题出现的频率越来越低,但仍然会出现。 1. 减少查询活动目录的次数。 2.出现问题时重置IIS。这并没有帮助。 3. 回收应用程序池。 4.重启sqlserver服务 5. 确保在引用服务器时使用完全限定名称。这似乎减少了一些问题。但不确定。我在 Windows 2008 服务器(64 位)上使用 IIS 7。
user = ConfigurationManager.AppSettings["TravelCardUser.AD_GroupName"];
approver = ConfigurationManager.AppSettings["TravelCardApprover.AD_GroupName"];
maintenance = ConfigurationManager.AppSettings["TravelCardMaintenance.AD_GroupName"];
admin = ConfigurationManager.AppSettings["TravelCardAdmin.AD_GroupName"];
testuser = ConfigurationManager.AppSettings["TestUser"];
List<string> adgroups = new List<string>();
adgroups.Add(admin);
adgroups.Add(approver);
adgroups.Add(maintenance);
adgroups.Add(user);
this.groups = adgroups;
List<string> groupmembership = new List<string>();
foreach (var group in groups)
{
if (!String.IsNullOrEmpty(testuser))
{
this.username = testuser;
}
else
{
this.username = currentloggedinuser;
}
using (var ctx = new PrincipalContext(ContextType.Domain))
using (var groupPrincipal = GroupPrincipal.FindByIdentity(ctx, group))
using (var userPrincipal = UserPrincipal.FindByIdentity(ctx, username))
{
if (groupPrincipal != null)
{
try
{
if (userPrincipal.IsMemberOf(groupPrincipal))
{
groupmembership.Add(group);
}
}
catch (Exception ex)
{
string theexception = ex.ToString();
}
}
}
}
这是我的 LDAP 连接字符串。
<add name="ADConnectionString_UserRole" connectionString="LDAP://locationX/cn=TravelCardUser,ou=LocationXgroupsGroups,dc=acme,dc=us,dc=com" />
I have an asp.net mvc web site on an intranet. Access to the site is determined by groups in active directory. There are 4 different groups each having different access in the site. I have been having occasional problems with the site running slowly. The site will run fine for several days then suddenly slow to a crawl. I have both a test site and a production site. When the slowdown occurs both sites are affected equally. I also have a site that test site that has no active directory access and it runs with no problems while these two sites are crawling. The sites I am having trouble are running under a user account because the application has to reach out to another share on the intranet in order to print and merge pdf files. The sites are running under the same application pool. When the problem occurs, all pages are equally slow even pages with no database activity. When the problem occurs I reset IIS, restart the web sites, and recycle the threads. The only thing that actually resolves the problem is restarting the server. Sometimes it takes a additional restart to get the site back to normal. Here are a few things I have tried. It seems the problem is occurring less often but still occurs.
1. Reduce the numbers of times that I query active directory.
2. Reset IIS when the problem occurs. This has not been helping.
3. Recycle application pools.
4. Restart the sql server service
5. Made sure fully qualified names are used when referring to servers. This seems to have reduced the problems some. Not sure though. I am using IIS 7 on a windows 2008 server, 64 bit.
user = ConfigurationManager.AppSettings["TravelCardUser.AD_GroupName"];
approver = ConfigurationManager.AppSettings["TravelCardApprover.AD_GroupName"];
maintenance = ConfigurationManager.AppSettings["TravelCardMaintenance.AD_GroupName"];
admin = ConfigurationManager.AppSettings["TravelCardAdmin.AD_GroupName"];
testuser = ConfigurationManager.AppSettings["TestUser"];
List<string> adgroups = new List<string>();
adgroups.Add(admin);
adgroups.Add(approver);
adgroups.Add(maintenance);
adgroups.Add(user);
this.groups = adgroups;
List<string> groupmembership = new List<string>();
foreach (var group in groups)
{
if (!String.IsNullOrEmpty(testuser))
{
this.username = testuser;
}
else
{
this.username = currentloggedinuser;
}
using (var ctx = new PrincipalContext(ContextType.Domain))
using (var groupPrincipal = GroupPrincipal.FindByIdentity(ctx, group))
using (var userPrincipal = UserPrincipal.FindByIdentity(ctx, username))
{
if (groupPrincipal != null)
{
try
{
if (userPrincipal.IsMemberOf(groupPrincipal))
{
groupmembership.Add(group);
}
}
catch (Exception ex)
{
string theexception = ex.ToString();
}
}
}
}
Here is my ldap connection string.
<add name="ADConnectionString_UserRole" connectionString="LDAP://locationX/cn=TravelCardUser,ou=LocationXgroupsGroups,dc=acme,dc=us,dc=com" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
服务器每 3 或 4 天就会变慢,因此我关闭了应用程序的应用程序池,并使用 Sysinternals 监视进程 3 天。
http://technet.microsoft.com/en-us/sysinternals/bb896653
我看到与 sequal 服务器和 Team Foundation 服务器相关的进程正在获取资源,但没有释放它们。顺便说一下,我通过 Red Gate Memory Profiler 运行了我的 asp.net 代码,没有出现内存泄漏。现在我必须弄清楚如何解决内存使用问题。
Ther server slows down every 3 or 4 days so I shut down the application pools to my applications and used Sysinternals to monitor process for 3 days.
http://technet.microsoft.com/en-us/sysinternals/bb896653
I am seeing that processes related to sequal server and team foundation server are grabbing resources but not releasing them. By the way I ran my asp.net code through Red Gate Memory Profiler and there are no memory leaks. Now I have to figure out what to do about the problem with memory usage.