質問
私はHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
、レジストリからのSIDのリストを読みます。
どのように1が表示名を解決します(例えばDOMAIN\user
、BUILT-IN\user
)C#でSID文字列を与えられた?
解決
Win32 API関数<のhref = "http://msdn.microsoft.com/en-us/library/windows/desktop/aa379166%28v=vs.85%29.aspx" のrel = "nofollowをnoreferrer" > LookupAccountSid()
するがSIDに対応する名前を検索するために使用されます。
LookupAccountSid()
は、次のシグネチャがあります。
BOOL LookupAccountSid(LPCTSTR lpSystemName, PSID Sid,LPTSTR Name, LPDWORD cbName,
LPTSTR ReferencedDomainName, LPDWORD cbReferencedDomainName,
PSID_NAME_USE peUse);
ます。http:// WWW ここでP /(サンプルコード付き)の参照を起動します.pinvoke.net / default.aspxを/ advapi32.LookupAccountSidする
[DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError = true)]
static extern bool LookupAccountSid (
string lpSystemName,
[MarshalAs(UnmanagedType.LPArray)] byte[] Sid,
StringBuilder lpName,
ref uint cchName,
StringBuilder ReferencedDomainName,
ref uint cchReferencedDomainName,
out SID_NAME_USE peUse);
他のヒント
ただ、 pinvoke.net の上でそれを見つけます。
オルタナティブマネージドAPI: .NET 2.0で利用可能:
using System.Security.Principal;
// convert the user sid to a domain\name
string account = new SecurityIdentifier(stringSid).Translate(typeof(NTAccount)).ToString();
所属していません StackOverflow