|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
SID to dotnet SecurityIdentifierFrom my research, SID's are supposed to be stored in an SQL database as a
varbinary(85). What is the best way to translate the SID to the dotnet 2.0 SecurityIdentifier type? I am working in C# but can probably translate VB code over as well if that way is easier to explain. Thanks for your time! -Edgars Klepers > From my research, SID's are supposed to be stored in an SQL database as a SecurityDescriptor.MaxBinaryLength is currently 68 in .Net framework 2.0.> varbinary(85). > What is the best way to translate the SID to the dotnet 2.0 If you have the byte array with SID, you can use the overloaded > SecurityIdentifier type? SecurityIdentifier constructor: SqlCommand command = new SqlCommand("SELECT SID FROM MyTable WHERE AccountName = 'MyDomain\MyAccount'", connection); byte[] sid = (byte[]) command.ExecuteScalar(); SecurityIdentifier si = new SecurityIdentifier(sid, 0); -- Show quoteHappy Holidays Dan Guzman SQL Server MVP "Edgars Klepers" <EdgarsKlep***@discussions.microsoft.com> wrote in message news:73E900FD-8803-48F2-B14E-23310C4192EB@microsoft.com... > From my research, SID's are supposed to be stored in an SQL database as a > varbinary(85). > > What is the best way to translate the SID to the dotnet 2.0 > SecurityIdentifier type? > > I am working in C# but can probably translate VB code over as well if that > way is easier to explain. > > Thanks for your time! > > -Edgars Klepers So from an SqlDataReader, i would just GetType(x) and typecast it to a
byte[]? or is there a better way to get it? Show quote "Dan Guzman" wrote: > > From my research, SID's are supposed to be stored in an SQL database as a > > varbinary(85). > > SecurityDescriptor.MaxBinaryLength is currently 68 in .Net framework 2.0. > > > What is the best way to translate the SID to the dotnet 2.0 > > SecurityIdentifier type? > > If you have the byte array with SID, you can use the overloaded > SecurityIdentifier constructor: > > SqlCommand command = > new SqlCommand("SELECT SID FROM MyTable WHERE AccountName = > 'MyDomain\MyAccount'", connection); > > byte[] sid = (byte[]) command.ExecuteScalar(); > > SecurityIdentifier si = new SecurityIdentifier(sid, 0); > > -- > Happy Holidays > > Dan Guzman > SQL Server MVP > > "Edgars Klepers" <EdgarsKlep***@discussions.microsoft.com> wrote in message > news:73E900FD-8803-48F2-B14E-23310C4192EB@microsoft.com... > > From my research, SID's are supposed to be stored in an SQL database as a > > varbinary(85). > > > > What is the best way to translate the SID to the dotnet 2.0 > > SecurityIdentifier type? > > > > I am working in C# but can probably translate VB code over as well if that > > way is easier to explain. > > > > Thanks for your time! > > > > -Edgars Klepers > > > You could use GetValue (rather than GetType) then cast. You could also use
GetBytes. -- Show quoteHappy Holidays Dan Guzman SQL Server MVP "Edgars Klepers" <EdgarsKlep***@discussions.microsoft.com> wrote in message news:C08A4495-D87A-4409-A6C0-F1E9915D5BBB@microsoft.com... > So from an SqlDataReader, i would just GetType(x) and typecast it to a > byte[]? or is there a better way to get it? > > "Dan Guzman" wrote: > >> > From my research, SID's are supposed to be stored in an SQL database as >> > a >> > varbinary(85). >> >> SecurityDescriptor.MaxBinaryLength is currently 68 in .Net framework 2.0. >> >> > What is the best way to translate the SID to the dotnet 2.0 >> > SecurityIdentifier type? >> >> If you have the byte array with SID, you can use the overloaded >> SecurityIdentifier constructor: >> >> SqlCommand command = >> new SqlCommand("SELECT SID FROM MyTable WHERE AccountName = >> 'MyDomain\MyAccount'", connection); >> >> byte[] sid = (byte[]) command.ExecuteScalar(); >> >> SecurityIdentifier si = new SecurityIdentifier(sid, 0); >> >> -- >> Happy Holidays >> >> Dan Guzman >> SQL Server MVP >> >> "Edgars Klepers" <EdgarsKlep***@discussions.microsoft.com> wrote in >> message >> news:73E900FD-8803-48F2-B14E-23310C4192EB@microsoft.com... >> > From my research, SID's are supposed to be stored in an SQL database as >> > a >> > varbinary(85). >> > >> > What is the best way to translate the SID to the dotnet 2.0 >> > SecurityIdentifier type? >> > >> > I am working in C# but can probably translate VB code over as well if >> > that >> > way is easier to explain. >> > >> > Thanks for your time! >> > >> > -Edgars Klepers >> >> >> Bah, i can't believe i didnt see the getBytes(); Thanks for your help :)
-Edgars Show quote "Dan Guzman" wrote: > You could use GetValue (rather than GetType) then cast. You could also use > GetBytes. > > -- > Happy Holidays > > Dan Guzman > SQL Server MVP > > "Edgars Klepers" <EdgarsKlep***@discussions.microsoft.com> wrote in message > news:C08A4495-D87A-4409-A6C0-F1E9915D5BBB@microsoft.com... > > So from an SqlDataReader, i would just GetType(x) and typecast it to a > > byte[]? or is there a better way to get it? > > > > "Dan Guzman" wrote: > > > >> > From my research, SID's are supposed to be stored in an SQL database as > >> > a > >> > varbinary(85). > >> > >> SecurityDescriptor.MaxBinaryLength is currently 68 in .Net framework 2.0. > >> > >> > What is the best way to translate the SID to the dotnet 2.0 > >> > SecurityIdentifier type? > >> > >> If you have the byte array with SID, you can use the overloaded > >> SecurityIdentifier constructor: > >> > >> SqlCommand command = > >> new SqlCommand("SELECT SID FROM MyTable WHERE AccountName = > >> 'MyDomain\MyAccount'", connection); > >> > >> byte[] sid = (byte[]) command.ExecuteScalar(); > >> > >> SecurityIdentifier si = new SecurityIdentifier(sid, 0); > >> > >> -- > >> Happy Holidays > >> > >> Dan Guzman > >> SQL Server MVP > >> > >> "Edgars Klepers" <EdgarsKlep***@discussions.microsoft.com> wrote in > >> message > >> news:73E900FD-8803-48F2-B14E-23310C4192EB@microsoft.com... > >> > From my research, SID's are supposed to be stored in an SQL database as > >> > a > >> > varbinary(85). > >> > > >> > What is the best way to translate the SID to the dotnet 2.0 > >> > SecurityIdentifier type? > >> > > >> > I am working in C# but can probably translate VB code over as well if > >> > that > >> > way is easier to explain. > >> > > >> > Thanks for your time! > >> > > >> > -Edgars Klepers > >> > >> > >> > > > |
|||||||||||||||||||||||