PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Re: Connection string problems using hexadecimal characters
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Re: Connection string problems using hexadecimal characters
![]() |
Re: Connection string problems using hexadecimal characters |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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 > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
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 >> |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

