这是确定用户TokenSize的可接受方式:
//TokenSize = 1200 + 40d + 8s
//http://support.microsoft.com/kb/327825/en-us
int TSize = 1200;
UserPrincipal user = UserPrincipal.FindByIdentity
(new PrincipalContext(ContextType.Domain, Environment.UserDomainName), IdentityType.SamAccountName, Environment.UserName);
foreach (GroupPrincipal group in user.GetGroups())
{
if (group.IsSecurityGroup == true)
if (group.GroupScope == GroupScope.Global)
TSize = TSize + 8;
else
TSize = TSize + 40;
}
SIDHistory怎么样?他们怎么能被统计?
谢谢!
答案 0 :(得分:0)
KB已告诉您这是一个估计值。它被用作系统管理员设置MaxTokenSize注册表项的指南。
This formula uses the following values:
d: The number of domain local groups a user is a member of plus the number of universal groups outside the user's account domain plus the number of groups represented in security ID (SID) history.
s: The number of security global groups that a user is a member of plus the number of universal groups in a user's account domain.
1200: The estimated value for ticket overhead. This value can vary depending on factors such as DNS domain name length, client name, and other factors.
In scenarios in which delegation is used (for example, when users authenticate to a domain controller), Microsoft recommends that you double the token size.
为什么需要计算令牌大小?只是想确保你没有将它与流程令牌混淆。
此处的令牌表示通常由SSP缓存和维护的Kerberos票证或NTLM令牌。由于它是一个非常敏感的信息,因此受到高度保护,您通常无法从用户模式应用程序访问它。应用程序通常处理的令牌是进程令牌,它与此KB描述的令牌不同。但是,Kerberos票证或NTLM令牌确实包含大量授权信息,最终用于生成进程令牌。我不记得进程令牌上有最大令牌大小限制。我可能错了。
关于 SidHistory 问题,我不确定我明白你的意思。这是我的理解。令牌包含一个组SID列表,该列表可能来自AD组对象的 SidHistory 。令牌本身不需要知道组SID是来自 SidHistory 还是 objectSid 。如果您的应用程序需要从令牌中存储的TOKEN_GROUPS信息中查找AD组对象,则您的应用程序需要针对 objectSid 以及 sidHistory 进行查询