相关疑难解决方法(0)

在Windows 7上调用IPrincipal.IsInRole

我们在应用程序中使用NTLM auth来确定用户是否可以执行某些操作.我们使用当前Windows登录的IPrincipal(在WinForms应用程序中),调用IsInRole来检查特定的组成员身份.

要检查用户是否是计算机上的本地管理员,我们使用:

AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
...
bool allowed = Thread.CurrentPrincipal.IsInRole(@"Builtin\Administrators")
Run Code Online (Sandbox Code Playgroud)

如果当前用户是Administrator用户,或者是该Builtin\Administrators组的成员的另一个用户,则此方法有效.

在我们对Windows 7的测试中,我们发现这不再按预期工作.该Administrator用户仍然能正常工作,但毕竟是成员的任何其他用户Builtin\Administrators组返回FALSE IsInRole调用.

什么可能导致这种差异?我有一种直觉感觉默认设置已经改变了(可能在gpedit中),但找不到任何看起来像罪魁祸首的东西.

.net c# security ntlm windows-7

8
推荐指数
2
解决办法
8773
查看次数

VB.NET和sizeof

我正在将一些代码从C#转换为VB.NET.我在C#中有以下行

var bytes = new byte[password.Length * sizeof(char)];
Run Code Online (Sandbox Code Playgroud)

MSDN上看来,VB.NET似乎没有sizeof运营商.我知道有一个Marshal.SizeOf但是进一步的MSDN文档声明返回的值可能与之不同sizeof.

有人可以帮忙吗?在VB.NET中是否有相同的声明?

附加信息

我的目标是将密码转换为字节数组,然后我可以散列,然后存储在数据库中或与之前存储的散列进行比较.但我不一定想得到与我的具体情况有关的答案.

Dim bytes(password.Length * xxx) As Byte
System.Buffer.BlockCopy(password.ToCharArray(), 0, bytes, 0, bytes.Length)
Dim sha512 = System.Security.Cryptography.SHA512.Create()
Dim hash = sha512.ComputeHash(bytes)

' compare hash or stroe in database
Run Code Online (Sandbox Code Playgroud)

.net c# vb.net sizeof

7
推荐指数
1
解决办法
6857
查看次数

标签 统计

.net ×2

c# ×2

ntlm ×1

security ×1

sizeof ×1

vb.net ×1

windows-7 ×1