Re: Connection string information

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Well I managed to reproduce the parser from SqlConnectionString and it
works. And it seems that MS saw that these kind of features were missing as
in ADO.NET 2 these properties are exposed.

Well to conclude, the believing that those values were not parsed was wrong.
Well about how the connection is actually made from .Net to SQL Server, if
you have some links mentioning about that, I would be glad to read about it
to know how it actually works. In the past I really did not believe that the
connection string was sent to the SQL Server but since your post, I am not
sure about it anymore. And I would tend to believe you as you seem to be
know more than me about it but I would like to read about it more
extensively. Then I could finally fully understand what's going on in there.

Thank you for your help.
Best regards,

Francois.


"William (Bill) Vaughn" <billvaRemoveThis@xxxxxxxxxx> wrote in message
news:egeLUuV4FHA.3976@xxxxxxxxxxxxxxxxxxxxxxx
> Right. And they are private--not exposed by ADO.NET
>
> --
> ____________________________________
> 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.
> __________________________________
>
> "Francois Malgreve" <francois.malgreveADgmail.com> wrote in message
> news:OSdavZQ4FHA.476@xxxxxxxxxxxxxxxxxxxxxxx
> > Well, I just decompiled the SQLConnection class.
> > I saw a lot of properties definned such as:
> >
> > private string _userID;
> > private string _password;
> >
> > internal string UserID
> > {
> > get
> > {
> > return _userID;
> > }
> > }
> >
> > internal string Password
> > {
> > get
> > {
> > return _password;
> > }
> > }
> >
> > Also I saw those values being assigned in some places:
> >
> > I also saw that there was a parser in the class SQLConnectionString
> > inherited from DBConnectionString but my decompiler was not good enough
to
> > decompile it completely. I can more or less read it but I cannot copy
> > paste
> > it in my own class to be able to re-use it :(
> >
> > It seemed that the parser stored EVERY value found from the conection
> > string
> > into an Hahstable, as long as the value exists, otherwise the value will
> > be
> > kept blank. Also I did not see anything that makes the parser skip some
> > elements. If an element exists within the connection string it parses
it,
> > except if that element is not a proper keyword then an exception is
thrown
> > (such as u put in passeword instead of password)
> > At the end of the constructor of DBConnectionString, a method
> > ValidateParse() is called and that method is overridden in
> > SQLConnectionString to set values for all properties that are in the
> > connection string (including passwords, user name and anything u can
> > define
> > into a connection string). Of course if a property is not defined in the
> > connection string then the equivalent property in SQLConnectionString
will
> > remain empty.
> >
> > Well, do you have a properly decompiled version of the System.Data.dll
> > that
> > you can actually recompile? I believe MS still does not publish the
source
> > code of the Framework API, do they?
> > And if I could run it i am pretty sure i could retrieve the user name
> > password.
> >
> > Last, sorry in advance to be so stubborn.
> >
> > Francois.
> >
> > "William (Bill) Vaughn" <billvaRemoveThis@xxxxxxxxxx> wrote in message
> > news:OMkEHLM4FHA.3592@xxxxxxxxxxxxxxxxxxxxxxx
> >> Unless the ConnectionString contains "Persist Security Info=true"
> >> referencing the ConnectionString assigned to a Connection won't return
> >> the
> >> credentials. If it is enabled, you'll have to do a string parse on the
> >> ConnectionString for the values. When ADO.NET assigns the
> >> ConnectionString
> >> to a Connection object, it parses the string and picks off key elements
> >> which are assigned to the Connection properties behind the scenes. Not
> >> all
> >> of the key/value pairs are used to set properties--the user id and
> > password
> >> are not assigned to properties.
> >>
> >> 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.
> >> __________________________________
> >>
> >> "Francois Malgreve" <francois.malgreveADgmail.com> wrote in message
> >> news:%23F3Gz9G4FHA.744@xxxxxxxxxxxxxxxxxxxxxxx
> >> > Hi,
> >> >
> >> > I would like to know how I can do to retrieve the user and password
> >> > from
> > a
> >> > connection object.
> >> > All i see from SQLConnection is that i can access the
connectionString
> > but
> >> > I
> >> > need to be able to access the specific user and password for that
> >> > connection.
> >> > If I parse the connection string myself i may not be able to catch
the
> >> > values properly every times as there are many valid syntax to build a
> >> > connection string and I am pretty sure that I do not know all of
them.
> >> > For example
> >> > "Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;"
> >> > is valid but
> >> > "Data Source=Aron1;Initial Catalog=pubs;User Id = sa;Password =
> >> > asdasd;"
> >> > "Data Source=Aron1;Initial Catalog=pubs;uid=sa;Password =asdasd;"
> >> > "Data Source=Aron1;Initial Catalog=pubs;uid =sa;pwd=asdasd;"
> >> > and probably other syntaxes are valid.
> >> >
> >> > I assume that internally the SqlConnection object parses the
connection
> >> > string and store the user and password in separate fields. Is there
any
> >> > public method or attribuate that can do that? Or any third party
> > library?
> >> >
> >> > Best regards,
> >> >
> >> > Francois Malgreve.
> >> >
> >> >
> >>
> >>
> >
> >
>
>


.



Relevant Pages

  • Re: [SOLVED] Cannot display provider-specific login prompt
    ... scenario where the program wouldn't have to know about the database, ... ConnectionStringBuilder up to a PropertyGrid for the end user to populate), ... details of the connection, for the sake of the program being able to connect ... information about the connection string that I will need. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Complicated Connection Problems bewteen ADP and SQL Server
    ... front end on the 5-8 workstations where the users happen to sit. ... expertise for getting the user workstations talking to the SQL Server. ... connection would fail and the adp wouldn't be able to talk to the server. ... thought that I should instead change my connection string to something ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Fujitsu NetCobol 8.0
    ... You cannot use a connection string in the way you have shown and expect it ... Any Fujitsu NetCobol / PowerCobol users here? ... Use the ADO control provided in PowerCOBOL, ...
    (comp.lang.cobol)
  • Re: Changing Connection String programmatically
    ... This is a good situation for putting the connection string information in the app.config file. ... every year we will create new database. ... change the body of the private void InitConnection(), ...
    (microsoft.public.sqlserver.connect)
  • Re: ASP.net and Oracle error System.Data.OleDb.OleDbException
    ... Also see http://www.connectionstrings.com/ and try other providers ... > Here is some of my connection code: ... >> And are you sure your connection string is ok. ... >>> Oracle error occurred, but error message could not be retrieved from ...
    (microsoft.public.dotnet.framework.aspnet)