Hi, Ich hab ein Problem mit einer SID unter Windows
(Jeder Benutzer,Gruppe,.. hat eine)
Sie kann z.B. folgendermasen aussehen:
S-1-3-2
S-1-5-32-551
S-1-5-21-842925246-1060284298-1957994488-500
S-1-5-21-842925246-1060284298-1957994488-1003
Sie Ist als OctetString gespeichert. Die Array Länge geht bis Max 28 stellen
Das waren schon mal ein paar Anhaltspunkte.
Das Problem ist, Ich bräuchte daraus ein ByteArray, so wie es z.B. in AD abgelegt wird..
Vielleicht hat jemand ja schonmal sowas gemacht und kann mir weiterhelfen.
Gruß Horego
Ne, Die Umwandlung geht über einen anderen weg, der leider nicht so einfach ist..
Gruß Horego
das machst du über den aufruf der api-funtion "ConvertSidStringToSid"
using System;
using System.Runtime.InteropServices;
...
...
[DllImport("advapi32.dll", EntryPoint = "ConvertStringSidToSid", CharSet=CharSet.Unicode)]
private static extern bool ConvertStringSidToSid(
[In,MarshalAs(UnmanagedType.LPTStr)]
string SIDString,
ref IntPtr pSID);
[DllImport("advapi32.dll", EntryPoint = "GetLengthSid", CharSet=CharSet.Auto)]
private static extern int GetLengthSid(
IntPtr pSID);
public static byte[] ConvertSIDStringToSID(string SID)
{
IntPtr pointer = IntPtr.Zero;
if (ConvertStringSidToSid(SID, ref pointer))
{
int size = GetLengthSid(pointer);
byte[] retVal = new byte[size];
Marshal.Copy(pointer, retVal, 0, size);
Marshal.FreeHGlobal(pointer);
return retVal;
}
else
{
Marshal.FreeHGlobal(pointer);
return null;
}
}
grtz
chief
Ahh Vielen Dank!
Genau das was ich brauche..
Hmm hätt ich gewusst das es da ne API gibt 😉
Naja kann nicht alles wissen X( ....
Besten Dank!
Gruß Horego