|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Connection string problems using hexadecimal charactersI 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? 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 How have you specified the hexed password in the connection string? Have> 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? you by any chance used a language specific hex identifier like &H for VB or 0x for C#? 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 Show quote "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 > 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 -- Show quote____________________________________ 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" <Steph***@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 >> |
|||||||||||||||||||||||