Discussions  >  SharpSvn Community Support and Feedback  >  RE: [SharpSvn] How I save de Authentication Data?

Back to topic list

RE: [SharpSvn] How I save de Authentication Data?

Author rhuijben (OCN Member)
Full name Bert Huijben
Date 2008-10-28 05:20:43 PDT
Message > -----Original Message-----
> From: Antonio de Castro [mailto:projectgroup​31{a}7comm.com.br]
> Sent: dinsdag 28 oktober 2008 12:33
> To: XXXX@XXXX; Bert Huijben
> Subject: RE: [SharpSvn] How I save de Authentication Data?
>
> Hi,
>
> I use Save property but it is not work.
> My application is in C# Windows Forms:
>
> private void Autenticar()
>
> {
>
> SvnClient _Client = new SvnClient();
>
> UsernamePasswordDialog usrpswd =
>
> new UsernamePasswordDialog();
>
>
>
> CheckBox chkB = (CheckBox)usrpswd.Controls[2];
>
>
>
> if(_check)
>
> {
>
> usrpswd.Controls[4].Text = _userNamePassword[0];
>
> usrpswd.Controls[3].Text = _userNamePassword[1];
>
> chkB.Checked = true;
>
> }
>
>
>
> usrpswd.ShowDialog();
>
>
>
> if (usrpswd.DialogResul​t.Equals(DialogResul​t.OK))
>
> {
>
> _Client.Authenticati​on.DefaultCredential​s =
>
> new NetworkCredential(us​rpswd.Controls[4].Te​xt,
>
> usrpswd.Controls[3].Text);
>
>
>
> _Client.Authenticati​on.UserNamePasswordH​andlers +=
>
> new
> EventHandler<SvnU​serNamePasswordEvent​Args>(Authenticat​ion_UserNamePassw
> ordHandlers);
>
>
>
> _cancel = false;
>
> }
>
> else
>
> _cancel = true;
>
>
>
> if (_check = chkB.Checked)
>
> {
>
> _userNamePassword[0] = usrpswd.Controls[4].Text;
>
> _userNamePassword[1] = usrpswd.Controls[3].Text;
>
> }
>
> }
>
>
>
> void Authentication_UserN​amePasswordHandlers(​object sender,
> SvnUserNamePasswordEventArgs e)
>
> {
>
> e.Save = true;


Why don't you set the username and password fields here?

The SharpSvn.UI dll uses the following code:
(See
http://sharpsvn.open​.collab.net/svn/shar​psvn/trunk/src/Sharp​Svn.UI/SvnClient
UIHandler.cs)

void DialogUserNamePasswo​rdHandler(Object sender,
SvnUserNamePasswordEventArgs e)
        {
            string description = SharpSvnGui.MakeDesc​ription(e.Realm,
Strings.TheServerXat​YRequiresAUsernameAn​dPassword);

            using (UsernamePasswordDialog dlg = new
UsernamePasswordDialog())
            {
                dlg.Text = Strings.ConnectToSubversion;
                dlg.descriptionBox.Text = description;
                dlg.descriptionBox.Visible = true;
                dlg.rememberCheck.Enabled = e.MaySave;
                if (Image != null)
                    dlg.SetImage(Image);

                if (!string.IsNullOrEmp​ty(e.InitialUserName​))
                {
                    dlg.usernameBox.Text = e.InitialUserName;
                    dlg.passwordBox.Select();
                }

                DialogResult r = RunDialog(dlg);

                if (r != DialogResult.OK)
                {
                    e.Save = dlg.rememberCheck.Checked;
                    e.UserName = e.Password = null;
                    e.Cancel = e.Break = true;
                    return;
                }

                e.UserName = dlg.usernameBox.Text;
                e.Password = dlg.passwordBox.Text;
                e.Save = e.MaySave && dlg.rememberCheck.Checked;
            }
        }

And this works correctly for all the AnkhSVN users.

You should either use DefaultCredentials or the handler. (DefaultCredentials
is just a simple event handler that sets the .UserName and .Password
properties)

    Bert

>
> }
>
> Thanks!
>
>
> > > -----Original Message-----
> > > From: Antonio de Castro [mailto:projectgroup​31{a}7comm.com.br]
> > > Sent: maandag 27 oktober 2008 19:25
> > > To: XXXX@XXXX
> > > Subject: [SharpSvn] How I save de Authentication Data?
> > >
> > > Hi,
> > >
> > > I need learn how to save the Authentication Data in client with
> > > sharpSVN. I am using C#.
> > > Anybody can post a example?
> >
> > If you receive an authentication request via one of the events on the
> > authenticator class, you can set the Save property to true to make
> its value
> > persistent.
> >
> > See the sourcecode of the SharpSvn.UI assembly for some examples.
> >
> http://sharpsvn.open​.collab.net/svn/shar​psvn/trunk/src/Sharp​Svn.UI/SvnC
> lient
> > UIHandler.cs
> > (Username: guest with no password, or your open collabnet login)
> >
> > Bert
> >
> > >
> > > Thanks!
> > >
> > > --------------------​--------------------​--------------
> > >
> http://sharpsvn.open​.collab.net/ds/viewM​essage.do?dsForumId=​728&dsMessa
> > > geId=139474
>
> --------------------​--------------------​--------------
> http://sharpsvn.open​.collab.net/ds/viewM​essage.do?dsForumId=​728&dsMessa
> geId=140624

« Previous message in topic | 4 of 9 | Next message in topic »

Messages

Show all messages in topic

[SharpSvn] How I save de Authentication Data? antoniodecastro (OCN Member) Antonio de Castro 2008-10-27 11:25:01 PDT
     RE: [SharpSvn] How I save de Authentication Data? rhuijben (OCN Member) Bert Huijben 2008-10-28 03:17:20 PDT
         RE: [SharpSvn] How I save de Authentication Data? antoniodecastro (OCN Member) Antonio de Castro 2008-10-28 04:33:07 PDT
             RE: [SharpSvn] How I save de Authentication Data? rhuijben (OCN Member) Bert Huijben 2008-10-28 05:20:43 PDT
             RE: [SharpSvn] How I save de Authentication Data? rhuijben (OCN Member) Bert Huijben 2008-10-28 05:24:03 PDT
                 RE: [SharpSvn] How I save de Authentication Data? antoniodecastro (OCN Member) Antonio de Castro 2008-10-28 05:56:53 PDT
                     RE: [SharpSvn] How I save de Authentication Data? antoniodecastro (OCN Member) Antonio de Castro 2008-10-28 06:00:18 PDT
                     RE: [SharpSvn] How I save de Authentication Data? rhuijben (OCN Member) Bert Huijben 2008-10-28 06:12:19 PDT
                         RE: [SharpSvn] How I save de Authentication Data? antoniodecastro (OCN Member) Antonio de Castro 2008-10-28 06:19:56 PDT
Messages per page: