By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,847 Members | 2,392 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,847 IT Pros & Developers. It's quick & easy.

system.byte[] and system.guid compare

P: n/a
Evening,

Wondering if someone can point me in the right direction, on how I would
compare a system.guid with a system.byte[].
system.guid (pulled from sql server table with a data type of
uniqueidentifier, originally taken from objectGUID from active directory
domain)

system.byte[] (objectGUID taken from active directory domain object)
I have an sql user table populated by a synchronisation with users from an
active directory domain, which works fine, with updates and new items added
to the domain, is changing or adding to the the sql user table. The problem
I'm experiencing is setting a field on the user table to true once the entry
is deleted, so historic records can be kept.

I'm currently selecting the ObjectGUID's (system.guid/unique identifier) for
all the users in the sql user table, I then select all the ObjectGUID's for
all users in the active directory. I then loop through each sql user record
and compare this with each record returned from the select on the active
directory records GUID, to see if the record still exists, if not then the
flag is set on the sql user table.

The problem is comparing the two values, any ideas, how do I convert a
system.guid to system.byte or system.byte to system.guid.
Many Thanks
Richard
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Dim myGuid As New Guid(MyByteArray())
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"rcolby" <rc*******@hotmailPLEASEREMOVE.com> wrote in message
news:41**********************@news.zen.co.uk...
Evening,

Wondering if someone can point me in the right direction, on how I would
compare a system.guid with a system.byte[].
system.guid (pulled from sql server table with a data type of
uniqueidentifier, originally taken from objectGUID from active directory
domain)

system.byte[] (objectGUID taken from active directory domain object)
I have an sql user table populated by a synchronisation with users from an active directory domain, which works fine, with updates and new items added to the domain, is changing or adding to the the sql user table. The problem I'm experiencing is setting a field on the user table to true once the entry is deleted, so historic records can be kept.

I'm currently selecting the ObjectGUID's (system.guid/unique identifier) for all the users in the sql user table, I then select all the ObjectGUID's for all users in the active directory. I then loop through each sql user record and compare this with each record returned from the select on the active
directory records GUID, to see if the record still exists, if not then the
flag is set on the sql user table.

The problem is comparing the two values, any ideas, how do I convert a
system.guid to system.byte or system.byte to system.guid.
Many Thanks
Richard

Nov 21 '05 #2

P: n/a
Terry,

Thanks for the quick replay, you will have to bear with me on this one. I'm
back into programming after a long period of inactivity and my computer
science degree seems to have gone missing from my brain cells.

This is what I think you are trying to showing me:

1. Dim mybytearray As Byte()
2.
3. 'Item to convert
4. mybytearray(0) = objActiveSearchResult.Properties("ObjectGUID")(0)
5.
6. 'convert to guid
7. Dim myGuid As New Guid(mybytearray(0))
8.
9. 'Check output
10. tester = myGuid.ToString
11. TextBox2.Text = tester
12.
13. SQL GUID IN DATADAPTER is Displayed.
14. 'Only used to test values
15.
16. tester2 = DataAdapter.Tables(0).Rows(i)(0).ToString (Convert GUID to
string)
17. TextBox2.Text = tester2 (RETURNS THE GUID) 'Display GUID in textbox

I receive a error when running line 4: Additional information: Cast from
type 'Byte()' to type 'Byte' is not valid.

Need more coffee, going to be something simple but coming from VB6 to this
all new object stuff is taking some getting used to.

Thanks
Richard

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:uN**************@TK2MSFTNGP09.phx.gbl...
Dim myGuid As New Guid(MyByteArray())
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"rcolby" <rc*******@hotmailPLEASEREMOVE.com> wrote in message
news:41**********************@news.zen.co.uk...
Evening,

Wondering if someone can point me in the right direction, on how I would
compare a system.guid with a system.byte[].
system.guid (pulled from sql server table with a data type of
uniqueidentifier, originally taken from objectGUID from active directory
domain)

system.byte[] (objectGUID taken from active directory domain object)
I have an sql user table populated by a synchronisation with users from

an
active directory domain, which works fine, with updates and new items

added
to the domain, is changing or adding to the the sql user table. The

problem
I'm experiencing is setting a field on the user table to true once the

entry
is deleted, so historic records can be kept.

I'm currently selecting the ObjectGUID's (system.guid/unique identifier)

for
all the users in the sql user table, I then select all the ObjectGUID's

for
all users in the active directory. I then loop through each sql user

record
and compare this with each record returned from the select on the active
directory records GUID, to see if the record still exists, if not then the flag is set on the sql user table.

The problem is comparing the two values, any ideas, how do I convert a
system.guid to system.byte or system.byte to system.guid.
Many Thanks
Richard


Nov 21 '05 #3

P: n/a

try something like this.

mybytearray = DirectCast(objActiveSearchResult.Properties("Objec tGUID"),
ByteArray)

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"rcolby" <rc*******@hotmailPLEASEREMOVE.com> wrote in message
news:41**********************@news.zen.co.uk...
Terry,

Thanks for the quick replay, you will have to bear with me on this one. I'm back into programming after a long period of inactivity and my computer
science degree seems to have gone missing from my brain cells.

This is what I think you are trying to showing me:

1. Dim mybytearray As Byte()
2.
3. 'Item to convert
4. mybytearray(0) = objActiveSearchResult.Properties("ObjectGUID")(0)
5.
6. 'convert to guid
7. Dim myGuid As New Guid(mybytearray(0))
8.
9. 'Check output
10. tester = myGuid.ToString
11. TextBox2.Text = tester
12.
13. SQL GUID IN DATADAPTER is Displayed.
14. 'Only used to test values
15.
16. tester2 = DataAdapter.Tables(0).Rows(i)(0).ToString (Convert GUID to string)
17. TextBox2.Text = tester2 (RETURNS THE GUID) 'Display GUID in textbox

I receive a error when running line 4: Additional information: Cast from
type 'Byte()' to type 'Byte' is not valid.

Need more coffee, going to be something simple but coming from VB6 to this
all new object stuff is taking some getting used to.

Thanks
Richard

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:uN**************@TK2MSFTNGP09.phx.gbl...
Dim myGuid As New Guid(MyByteArray())
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"rcolby" <rc*******@hotmailPLEASEREMOVE.com> wrote in message
news:41**********************@news.zen.co.uk...
Evening,

Wondering if someone can point me in the right direction, on how I would compare a system.guid with a system.byte[].
system.guid (pulled from sql server table with a data type of
uniqueidentifier, originally taken from objectGUID from active directory domain)

system.byte[] (objectGUID taken from active directory domain object)
I have an sql user table populated by a synchronisation with users from
an
active directory domain, which works fine, with updates and new items

added
to the domain, is changing or adding to the the sql user table. The

problem
I'm experiencing is setting a field on the user table to true once the

entry
is deleted, so historic records can be kept.

I'm currently selecting the ObjectGUID's (system.guid/unique
identifier)
for
all the users in the sql user table, I then select all the
ObjectGUID's for
all users in the active directory. I then loop through each sql user

record
and compare this with each record returned from the select on the

active directory records GUID, to see if the record still exists, if not then

the flag is set on the sql user table.

The problem is comparing the two values, any ideas, how do I convert a
system.guid to system.byte or system.byte to system.guid.
Many Thanks
Richard



Nov 21 '05 #4

P: n/a
Terry,

I've looked at each of your suggestions, and couldn't get anything
converted, I found this code from another post. At first I thought it didn't
work as the first 16 digits were not the same but the last 16 digits were,
wasn't until I read the post again that the code was correcting a jumbled up
GUID, I've changed the references to each bit in the arrays to be the same
reference and it seems to be work with the 20 test users I have tried
comparing the GUID's with. can you for see any problems doing the conversion
this way.

example:

Dim returnedGUID as guid

returnedGUID = bytetoGUID(objActiveSearchResult.Properties("Objec tGUID")(0)

textbox1.text = returnedGUID.tostring

textbox2.text = dtaSqlUsers.Tables(0).Rows(test)(0).ToString
Public Shared Function BytetoGUID(ByVal searcherGuid As Byte()) As Guid

Dim mapBytes(15) As Byte

mapBytes(0) = searcherGuid(0)

mapBytes(1) = searcherGuid(1)

mapBytes(2) = searcherGuid(2)

mapBytes(3) = searcherGuid(3)

mapBytes(4) = searcherGuid(4)

mapBytes(5) = searcherGuid(5)

mapBytes(6) = searcherGuid(6)

mapBytes(7) = searcherGuid(7)

mapBytes(8) = searcherGuid(8)

mapBytes(9) = searcherGuid(9)

mapBytes(10) = searcherGuid(10)

mapBytes(11) = searcherGuid(11)

mapBytes(12) = searcherGuid(12)

mapBytes(13) = searcherGuid(13)

mapBytes(14) = searcherGuid(14)

mapBytes(15) = searcherGuid(15)

Return New Guid(mapBytes)

End Function
Many thanks for your input, I'm bit dumb these days when it comes to
programming (object, what's an object).

Thanks
Richard

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:uE*************@TK2MSFTNGP12.phx.gbl...

try something like this.

mybytearray = DirectCast(objActiveSearchResult.Properties("Objec tGUID"),
ByteArray)

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"rcolby" <rc*******@hotmailPLEASEREMOVE.com> wrote in message
news:41**********************@news.zen.co.uk...
Terry,

Thanks for the quick replay, you will have to bear with me on this one. I'm
back into programming after a long period of inactivity and my computer
science degree seems to have gone missing from my brain cells.

This is what I think you are trying to showing me:

1. Dim mybytearray As Byte()
2.
3. 'Item to convert
4. mybytearray(0) = objActiveSearchResult.Properties("ObjectGUID")(0)
5.
6. 'convert to guid
7. Dim myGuid As New Guid(mybytearray(0))
8.
9. 'Check output
10. tester = myGuid.ToString
11. TextBox2.Text = tester
12.
13. SQL GUID IN DATADAPTER is Displayed.
14. 'Only used to test values
15.
16. tester2 = DataAdapter.Tables(0).Rows(i)(0).ToString (Convert GUID

to
string)
17. TextBox2.Text = tester2 (RETURNS THE GUID) 'Display GUID in textbox

I receive a error when running line 4: Additional information: Cast from
type 'Byte()' to type 'Byte' is not valid.

Need more coffee, going to be something simple but coming from VB6 to this all new object stuff is taking some getting used to.

Thanks
Richard

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message
news:uN**************@TK2MSFTNGP09.phx.gbl...
Dim myGuid As New Guid(MyByteArray())
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"rcolby" <rc*******@hotmailPLEASEREMOVE.com> wrote in message
news:41**********************@news.zen.co.uk...
> Evening,
>
> Wondering if someone can point me in the right direction, on how I would > compare a system.guid with a system.byte[].
>
>
> system.guid (pulled from sql server table with a data type of
> uniqueidentifier, originally taken from objectGUID from active directory > domain)
>
> system.byte[] (objectGUID taken from active directory domain object)
>
>
> I have an sql user table populated by a synchronisation with users from an
> active directory domain, which works fine, with updates and new items added
> to the domain, is changing or adding to the the sql user table. The
problem
> I'm experiencing is setting a field on the user table to true once the entry
> is deleted, so historic records can be kept.
>
> I'm currently selecting the ObjectGUID's (system.guid/unique identifier) for
> all the users in the sql user table, I then select all the ObjectGUID's for
> all users in the active directory. I then loop through each sql user
record
> and compare this with each record returned from the select on the active > directory records GUID, to see if the record still exists, if not then the
> flag is set on the sql user table.
>
> The problem is comparing the two values, any ideas, how do I convert
a > system.guid to system.byte or system.byte to system.guid.
>
>
> Many Thanks
> Richard
>
>




"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:uE*************@TK2MSFTNGP12.phx.gbl...
try something like this.

mybytearray = DirectCast(objActiveSearchResult.Properties("Objec tGUID"),
ByteArray)

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"rcolby" <rc*******@hotmailPLEASEREMOVE.com> wrote in message
news:41**********************@news.zen.co.uk...
Terry,

Thanks for the quick replay, you will have to bear with me on this one.

I'm
back into programming after a long period of inactivity and my computer
science degree seems to have gone missing from my brain cells.

This is what I think you are trying to showing me:

1. Dim mybytearray As Byte()
2.
3. 'Item to convert
4. mybytearray(0) = objActiveSearchResult.Properties("ObjectGUID")(0)
5.
6. 'convert to guid
7. Dim myGuid As New Guid(mybytearray(0))
8.
9. 'Check output
10. tester = myGuid.ToString
11. TextBox2.Text = tester
12.
13. SQL GUID IN DATADAPTER is Displayed.
14. 'Only used to test values
15.
16. tester2 = DataAdapter.Tables(0).Rows(i)(0).ToString (Convert GUID

to
string)
17. TextBox2.Text = tester2 (RETURNS THE GUID) 'Display GUID in textbox
I receive a error when running line 4: Additional information: Cast from
type 'Byte()' to type 'Byte' is not valid.

Need more coffee, going to be something simple but coming from VB6 to this all new object stuff is taking some getting used to.

Thanks
Richard

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message
news:uN**************@TK2MSFTNGP09.phx.gbl...
Dim myGuid As New Guid(MyByteArray())
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"rcolby" <rc*******@hotmailPLEASEREMOVE.com> wrote in message
news:41**********************@news.zen.co.uk...
> Evening,
>
> Wondering if someone can point me in the right direction, on how I would > compare a system.guid with a system.byte[].
>
>
> system.guid (pulled from sql server table with a data type of
> uniqueidentifier, originally taken from objectGUID from active directory > domain)
>
> system.byte[] (objectGUID taken from active directory domain object)
>
>
> I have an sql user table populated by a synchronisation with users from an
> active directory domain, which works fine, with updates and new items added
> to the domain, is changing or adding to the the sql user table. The
problem
> I'm experiencing is setting a field on the user table to true once the entry
> is deleted, so historic records can be kept.
>
> I'm currently selecting the ObjectGUID's (system.guid/unique identifier) for
> all the users in the sql user table, I then select all the ObjectGUID's for
> all users in the active directory. I then loop through each sql user
record
> and compare this with each record returned from the select on the active > directory records GUID, to see if the record still exists, if not then the
> flag is set on the sql user table.
>
> The problem is comparing the two values, any ideas, how do I convert

a > system.guid to system.byte or system.byte to system.guid.
>
>
> Many Thanks
> Richard
>
>



Nov 21 '05 #5

P: n/a
Glad u made it work.

A class is really a template for an instance of the class which is called an
Object.

Public Class Colby

Public initial As String = "R"

End Class

Dim rColby as New Colby 'Here you create an instance of Colby in memory
and pass its address to the identifier rColby. This is called Instantiation.
'// rColby is now an object of type Colby




"rcolby" <rc*******@hotmailPLEASEREMOVE.com> wrote in message
news:41**********************@news.zen.co.uk...
Terry,

I've looked at each of your suggestions, and couldn't get anything
converted, I found this code from another post. At first I thought it didn't work as the first 16 digits were not the same but the last 16 digits were,
wasn't until I read the post again that the code was correcting a jumbled up GUID, I've changed the references to each bit in the arrays to be the same
reference and it seems to be work with the 20 test users I have tried
comparing the GUID's with. can you for see any problems doing the conversion this way.

example:

Dim returnedGUID as guid

returnedGUID = bytetoGUID(objActiveSearchResult.Properties("Objec tGUID")(0)
textbox1.text = returnedGUID.tostring

textbox2.text = dtaSqlUsers.Tables(0).Rows(test)(0).ToString
Public Shared Function BytetoGUID(ByVal searcherGuid As Byte()) As Guid

Dim mapBytes(15) As Byte

mapBytes(0) = searcherGuid(0)

mapBytes(1) = searcherGuid(1)

mapBytes(2) = searcherGuid(2)

mapBytes(3) = searcherGuid(3)

mapBytes(4) = searcherGuid(4)

mapBytes(5) = searcherGuid(5)

mapBytes(6) = searcherGuid(6)

mapBytes(7) = searcherGuid(7)

mapBytes(8) = searcherGuid(8)

mapBytes(9) = searcherGuid(9)

mapBytes(10) = searcherGuid(10)

mapBytes(11) = searcherGuid(11)

mapBytes(12) = searcherGuid(12)

mapBytes(13) = searcherGuid(13)

mapBytes(14) = searcherGuid(14)

mapBytes(15) = searcherGuid(15)

Return New Guid(mapBytes)

End Function
Many thanks for your input, I'm bit dumb these days when it comes to
programming (object, what's an object).

Thanks
Richard

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:uE*************@TK2MSFTNGP12.phx.gbl...

try something like this.

mybytearray = DirectCast(objActiveSearchResult.Properties("Objec tGUID"),
ByteArray)

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"rcolby" <rc*******@hotmailPLEASEREMOVE.com> wrote in message
news:41**********************@news.zen.co.uk...
Terry,

Thanks for the quick replay, you will have to bear with me on this one.
I'm
back into programming after a long period of inactivity and my
computer science degree seems to have gone missing from my brain cells.

This is what I think you are trying to showing me:

1. Dim mybytearray As Byte()
2.
3. 'Item to convert
4. mybytearray(0) = objActiveSearchResult.Properties("ObjectGUID")(0) 5.
6. 'convert to guid
7. Dim myGuid As New Guid(mybytearray(0))
8.
9. 'Check output
10. tester = myGuid.ToString
11. TextBox2.Text = tester
12.
13. SQL GUID IN DATADAPTER is Displayed.
14. 'Only used to test values
15.
16. tester2 = DataAdapter.Tables(0).Rows(i)(0).ToString (Convert GUID
to
string)
17. TextBox2.Text = tester2 (RETURNS THE GUID) 'Display GUID in textbox
I receive a error when running line 4: Additional information: Cast
from type 'Byte()' to type 'Byte' is not valid.

Need more coffee, going to be something simple but coming from VB6 to
this all new object stuff is taking some getting used to.

Thanks
Richard

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message
news:uN**************@TK2MSFTNGP09.phx.gbl...
> Dim myGuid As New Guid(MyByteArray())
>
>
> --
>
> OHM ( Terry Burns )
> . . . One-Handed-Man . . .
>
> Time flies when you don't know what you're doing
>
> "rcolby" <rc*******@hotmailPLEASEREMOVE.com> wrote in message
> news:41**********************@news.zen.co.uk...
> > Evening,
> >
> > Wondering if someone can point me in the right direction, on how I

would
> > compare a system.guid with a system.byte[].
> >
> >
> > system.guid (pulled from sql server table with a data type of
> > uniqueidentifier, originally taken from objectGUID from active

directory
> > domain)
> >
> > system.byte[] (objectGUID taken from active directory domain object) > >
> >
> > I have an sql user table populated by a synchronisation with users from
> an
> > active directory domain, which works fine, with updates and new items > added
> > to the domain, is changing or adding to the the sql user table.
The > problem
> > I'm experiencing is setting a field on the user table to true once the > entry
> > is deleted, so historic records can be kept.
> >
> > I'm currently selecting the ObjectGUID's (system.guid/unique

identifier)
> for
> > all the users in the sql user table, I then select all the

ObjectGUID's
> for
> > all users in the active directory. I then loop through each sql user > record
> > and compare this with each record returned from the select on the

active
> > directory records GUID, to see if the record still exists, if not then the
> > flag is set on the sql user table.
> >
> > The problem is comparing the two values, any ideas, how do I convert a
> > system.guid to system.byte or system.byte to system.guid.
> >
> >
> > Many Thanks
> > Richard
> >
> >
>
>


"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message news:uE*************@TK2MSFTNGP12.phx.gbl...

try something like this.

mybytearray = DirectCast(objActiveSearchResult.Properties("Objec tGUID"),
ByteArray)

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"rcolby" <rc*******@hotmailPLEASEREMOVE.com> wrote in message
news:41**********************@news.zen.co.uk...
Terry,

Thanks for the quick replay, you will have to bear with me on this
one. I'm
back into programming after a long period of inactivity and my
computer science degree seems to have gone missing from my brain cells.

This is what I think you are trying to showing me:

1. Dim mybytearray As Byte()
2.
3. 'Item to convert
4. mybytearray(0) = objActiveSearchResult.Properties("ObjectGUID")(0) 5.
6. 'convert to guid
7. Dim myGuid As New Guid(mybytearray(0))
8.
9. 'Check output
10. tester = myGuid.ToString
11. TextBox2.Text = tester
12.
13. SQL GUID IN DATADAPTER is Displayed.
14. 'Only used to test values
15.
16. tester2 = DataAdapter.Tables(0).Rows(i)(0).ToString (Convert GUID to
string)
17. TextBox2.Text = tester2 (RETURNS THE GUID) 'Display GUID in textbox
I receive a error when running line 4: Additional information: Cast
from type 'Byte()' to type 'Byte' is not valid.

Need more coffee, going to be something simple but coming from VB6 to
this all new object stuff is taking some getting used to.

Thanks
Richard

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message
news:uN**************@TK2MSFTNGP09.phx.gbl...
> Dim myGuid As New Guid(MyByteArray())
>
>
> --
>
> OHM ( Terry Burns )
> . . . One-Handed-Man . . .
>
> Time flies when you don't know what you're doing
>
> "rcolby" <rc*******@hotmailPLEASEREMOVE.com> wrote in message
> news:41**********************@news.zen.co.uk...
> > Evening,
> >
> > Wondering if someone can point me in the right direction, on how I

would
> > compare a system.guid with a system.byte[].
> >
> >
> > system.guid (pulled from sql server table with a data type of
> > uniqueidentifier, originally taken from objectGUID from active

directory
> > domain)
> >
> > system.byte[] (objectGUID taken from active directory domain object) > >
> >
> > I have an sql user table populated by a synchronisation with users from
> an
> > active directory domain, which works fine, with updates and new items > added
> > to the domain, is changing or adding to the the sql user table.
The > problem
> > I'm experiencing is setting a field on the user table to true once

the > entry
> > is deleted, so historic records can be kept.
> >
> > I'm currently selecting the ObjectGUID's (system.guid/unique

identifier)
> for
> > all the users in the sql user table, I then select all the

ObjectGUID's
> for
> > all users in the active directory. I then loop through each sql user > record
> > and compare this with each record returned from the select on the

active
> > directory records GUID, to see if the record still exists, if not then the
> > flag is set on the sql user table.
> >
> > The problem is comparing the two values, any ideas, how do I
convert a > > system.guid to system.byte or system.byte to system.guid.
> >
> >
> > Many Thanks
> > Richard
> >
> >
>
>


Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.