C# WindowsIdentity-组和声明之间的差异
我试图使用SID-s检查用户是否属于某些组 我正在使用,但后来注意到,有时它并不表示该用户属于Administrators组 搜索了一段时间后,我发现它可以正常工作(包括结果中的admin组)。C# WindowsIdentity-组和声明之间的差异,c#,.net,windows-identity,C#,.net,Windows Identity,我试图使用SID-s检查用户是否属于某些组 我正在使用,但后来注意到,有时它并不表示该用户属于Administrators组 搜索了一段时间后,我发现它可以正常工作(包括结果中的admin组)。 我无法在上找到适当的文档 那么,WindowsIdentity中的组和声明之间有什么区别,为什么组不显示administrators组而声明显示administrators组? 最后,我可以安全地使用声明而不是组吗 以下是我的代码: var wi = WindowsIdentity.GetCurrent
我无法在上找到适当的文档 那么,WindowsIdentity中的组和声明之间有什么区别,为什么组不显示administrators组而声明显示administrators组?
最后,我可以安全地使用声明而不是组吗 以下是我的代码:
var wi = WindowsIdentity.GetCurrent();
var sidToFind = "S-1-5-32-544"; // Hardcoded the sid of administrators group for demo, but in general this is a parameter of a function on my side
// This will NOT include the sid S-1-5-32-544
var groupSids= wi.Groups
.Where(item => item.Value == sidToFind);
// This will include the sid S-1-5-32-544 and also all the other results that Groups provides.
var claimSids = wi.Claims
.Where(item => item.Value == sidToFind));
群体和主张之间存在差异
- 组与工作组和AD一起工作
- 索赔与Active Directory联合身份验证服务一起使用
如果您想通过SIDs检查特定用户是否属于某些组,将提供帮助。