PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Re: Connection string problems using hexadecimal characters

Reply

Re: Connection string problems using hexadecimal characters

 
Thread Tools Rate Thread
Old 28-12-2006, 04:04 PM   #1
Rad [Visual C# MVP]
Guest
 
Posts: n/a
Default Re: Connection string problems using hexadecimal characters


On Thu, 28 Dec 2006 07:22:00 -0800, Stephen K wrote:

> I am using the SQL server client to connect from a Vb .net windows forms
> application to a SQL server 2000 database. The user passwords are scrambled
> usign an XOR function and they are converted to hex characters. Using VB 6
> this all worked fine. Now under .Net the connection to the database fails. It
> appears that there is a real problem with the password portion of the
> connection string if it contains hexadecimal characters. That is if the
> users password is only alpha characters the connection to sql server works,
> but if it contains alpha and numerics the connection fails. Any ideas?


How have you specified the hexed password in the connection string? Have
you by any chance used a language specific hex identifier like &H for VB or
0x for C#?

--
Bits.Bytes
http://bytes.thinkersroom.com
  Reply With Quote
Old 29-12-2006, 12:09 AM   #2
=?Utf-8?B?U3RlcGhlbiBL?=
Guest
 
Posts: n/a
Default Re: Connection string problems using hexadecimal characters

Rad - Thank you for replying the code that sets the password string goes like
this

'XOR the text.
For lnIdx = 1 To Len(sReved)
nChar = Asc(Mid(sReved, lnIdx, 1))
If nChar > 49 And nChar < 57 Then
nChar = nChar + 8
End If
nChar = nChar Xor &H3F
If nChar = 0 Then nChar = 65
sXORed = sXORed & Chr(nChar)
Next

' If a ';' exists, only keep left of ';'
lnSemicolonPos = InStr(sXORed, ";")
If lnSemicolonPos <> 0 Then
sXORed = Left(sXORed, lnSemicolonPos - 1)
End If

Regards
Stephen

"Rad [Visual C# MVP]" wrote:

> On Thu, 28 Dec 2006 07:22:00 -0800, Stephen K wrote:
>
> > I am using the SQL server client to connect from a Vb .net windows forms
> > application to a SQL server 2000 database. The user passwords are scrambled
> > usign an XOR function and they are converted to hex characters. Using VB 6
> > this all worked fine. Now under .Net the connection to the database fails. It
> > appears that there is a real problem with the password portion of the
> > connection string if it contains hexadecimal characters. That is if the
> > users password is only alpha characters the connection to sql server works,
> > but if it contains alpha and numerics the connection fails. Any ideas?

>
> How have you specified the hexed password in the connection string? Have
> you by any chance used a language specific hex identifier like &H for VB or
> 0x for C#?
>
> --
> Bits.Bytes
> http://bytes.thinkersroom.com
>

  Reply With Quote
Old 29-12-2006, 12:45 AM   #3
William \(Bill\) Vaughn
Guest
 
Posts: n/a
Default Re: Connection string problems using hexadecimal characters

The only real difference in how ADO and ADO.NET handle the Connection object
is how the Password can be passed as a string to the Open method. Since
ADO.NET only accepts passwords in the Connection string, you'll have to
resolve the decryption at runtime and build the ConnectionString then.
Simply concatenate in the decoded password.

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"Stephen K" <StephenK@discussions.microsoft.com> wrote in message
news:74DE47A2-6231-4852-A812-169420E972AF@microsoft.com...
> Rad - Thank you for replying the code that sets the password string goes
> like
> this
>
> 'XOR the text.
> For lnIdx = 1 To Len(sReved)
> nChar = Asc(Mid(sReved, lnIdx, 1))
> If nChar > 49 And nChar < 57 Then
> nChar = nChar + 8
> End If
> nChar = nChar Xor &H3F
> If nChar = 0 Then nChar = 65
> sXORed = sXORed & Chr(nChar)
> Next
>
> ' If a ';' exists, only keep left of ';'
> lnSemicolonPos = InStr(sXORed, ";")
> If lnSemicolonPos <> 0 Then
> sXORed = Left(sXORed, lnSemicolonPos - 1)
> End If
>
> Regards
> Stephen
>
> "Rad [Visual C# MVP]" wrote:
>
>> On Thu, 28 Dec 2006 07:22:00 -0800, Stephen K wrote:
>>
>> > I am using the SQL server client to connect from a Vb .net windows
>> > forms
>> > application to a SQL server 2000 database. The user passwords are
>> > scrambled
>> > usign an XOR function and they are converted to hex characters. Using
>> > VB 6
>> > this all worked fine. Now under .Net the connection to the database
>> > fails. It
>> > appears that there is a real problem with the password portion of the
>> > connection string if it contains hexadecimal characters. That is if
>> > the
>> > users password is only alpha characters the connection to sql server
>> > works,
>> > but if it contains alpha and numerics the connection fails. Any ideas?

>>
>> How have you specified the hexed password in the connection string? Have
>> you by any chance used a language specific hex identifier like &H for VB
>> or
>> 0x for C#?
>>
>> --
>> Bits.Bytes
>> http://bytes.thinkersroom.com
>>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off