System.Data.SQLite
Check-in [7f1a54a5c2]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:no message
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sourceforge
Files: files | file ages | folders
SHA1: 7f1a54a5c23056c739a622aabf89d171113c10e2
User & Date: rmsimpson 2006-03-01 04:55:59
Context
2006-03-01
06:01
1.0.27.1 check-in: f680e44bbf user: rmsimpson tags: sourceforge
04:55
no message check-in: 7f1a54a5c2 user: rmsimpson tags: sourceforge
2006-02-27
05:23
no message check-in: 9e8c8737b8 user: rmsimpson tags: sourceforge
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added Membership/MembershipProvider/Initialize.cs.



























































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System.Web.Security;
using System.Configuration.Provider;
using System.Collections.Specialized;
using System;
using System.Data;
using System.Data.SQLite;
using System.Configuration;
using System.Diagnostics;
using System.Web;
using System.Globalization;
using System.Security.Cryptography;
using System.Text;
using System.Web.Configuration;



namespace SQLiteProvider
{

    public sealed partial class SQLiteMembershipProvider : MembershipProvider
    {
        public override void Initialize(string name, NameValueCollection config)
        {
            
            //
            // Initialize values from web.config.
            //

            if (config == null)
                throw new ArgumentNullException("config");

            if (name == null || name.Length == 0)
                name = "SQLiteMembershipProvider";

            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "SQLite Membership provider");
            }

            // Initialize the abstract base class.
            base.Initialize(name, config);


            _MaxInvalidPasswordAttempts = Convert.ToInt32(GetConfigValue(config["maxInvalidPasswordAttempts"], "5"));
            _PasswordAttemptWindow = Convert.ToInt32(GetConfigValue(config["passwordAttemptWindow"], "10"));
            _MinRequiredNonAlphanumericCharacters = Convert.ToInt32(GetConfigValue(config["minRequiredNonAlphanumericCharacters"], "1"));
            _MinRequiredPasswordLength = Convert.ToInt32(GetConfigValue(config["minRequiredPasswordLength"], "7"));
            _PasswordStrengthRegularExpression = Convert.ToString(GetConfigValue(config["passwordStrengthRegularExpression"], ""));
            _EnablePasswordReset = Convert.ToBoolean(GetConfigValue(config["enablePasswordReset"], "true"));
            _EnablePasswordRetrieval = Convert.ToBoolean(GetConfigValue(config["enablePasswordRetrieval"], "true"));
            _RequiresQuestionAndAnswer = Convert.ToBoolean(GetConfigValue(config["requiresQuestionAndAnswer"], "false"));
            _RequiresUniqueEmail = Convert.ToBoolean(GetConfigValue(config["requiresUniqueEmail"], "true"));
            
            string temp_format = config["passwordFormat"];
            if (temp_format == null)
            {
                temp_format = "Hashed";
            }

            switch (temp_format)
            {
                case "Hashed":
                    _PasswordFormat = MembershipPasswordFormat.Hashed;
                    break;
                case "Encrypted":
                    _PasswordFormat = MembershipPasswordFormat.Encrypted;
                    break;
                case "Clear":
                    _PasswordFormat = MembershipPasswordFormat.Clear;
                    break;
                default:
                    throw new ProviderException("Password format not supported.");
            }

            _WriteExceptionsToEventLog = ProviderUtility.GetExceptionDesitination(config["writeExceptionsToEventLog"]);
            connectionString = ProviderUtility.GetConnectionString(config["connectionStringName"]);
            ApplicationName = ProviderUtility.GetApplicationName(config["applicationName"]);


            // Get encryption and decryption key information from the configuration.
            Configuration cfg =
              WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
            machineKey = (MachineKeySection)cfg.GetSection("system.web/machineKey");

            if (machineKey.ValidationKey.Contains("AutoGenerate"))
                if (PasswordFormat != MembershipPasswordFormat.Clear)
                    throw new ProviderException("Hashed or Encrypted passwords " +
                                                "are not supported with auto-generated keys.");

            // Application Name has to be last since we use it to get our AppID
            this.ApplicationName = GetConfigValue(config["applicationName"],
                                System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
        }


        //
        // A helper function to retrieve config values from the configuration file.
        //

        private string GetConfigValue(string configValue, string defaultValue)
        {
            if (String.IsNullOrEmpty(configValue))
                return defaultValue;

            return configValue;
        }
    }
}

Added Membership/MembershipProvider/Membership.cs.



























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
using System.Web.Security;
using System.Web.Profile;
using System.Configuration.Provider;
using System.Collections.Specialized;
using System;
using System.Data;
using System.Data.SQLite;
using System.Configuration;
using System.Diagnostics;
using System.Web;
using System.Globalization;
using System.Security.Cryptography;
using System.Text;
using System.Web.Configuration;




namespace SQLiteProvider
{

    public sealed partial class SQLiteMembershipProvider : MembershipProvider
    {

        //
        // Global connection string, generated password length, generic exception message, event log info.
        //

        private int newPasswordLength = 8;
        private string eventSource = "SQLiteMembershipProvider";

        private string connectionString;
        private bool _WriteExceptionsToEventLog;
        private MachineKeySection machineKey;
        private string _ApplicationName;
        private long _AppID;
        private bool _EnablePasswordReset;
        private bool _EnablePasswordRetrieval;
        private bool _RequiresQuestionAndAnswer;
        private bool _RequiresUniqueEmail;
        private int _MaxInvalidPasswordAttempts;
        private int _PasswordAttemptWindow;
        private MembershipPasswordFormat _PasswordFormat;
     

        public bool WriteExceptionsToEventLog
        {
            get { return _WriteExceptionsToEventLog; }
            set { _WriteExceptionsToEventLog = value; }
        }






        public override bool ChangePassword(string username, string oldPwd, string newPwd)
        {
            if (!ValidateUser(username, oldPwd))
                return false;


            ValidatePasswordEventArgs args =
              new ValidatePasswordEventArgs(username, newPwd, true);

            OnValidatingPassword(args);

            if (args.Cancel)
                if (args.FailureInformation != null)
                    throw args.FailureInformation;
                else
                    throw new MembershipPasswordException("Change password canceled due to new password validation failure.");

            
            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(MembershipSql.ChangePassword , conn);

             
            cmd.Parameters.Add("$Password", DbType.String).Value = EncodePassword(newPwd);
            cmd.Parameters.Add("$Username", DbType.String).Value = username;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            int rowsAffected = 0;

            try
            {
                conn.Open();

                rowsAffected = cmd.ExecuteNonQuery();
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "ChangePassword", WriteExceptionsToEventLog);

            }
            finally
            {
                conn.Close();
            }

            if (rowsAffected > 0)
            {
                return true;
            }

            return false;
        }
        public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPwdQuestion, string newPwdAnswer)
        {
            if (!ValidateUser(username, password))
                return false;

            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(MembershipSql.ChangePasswordQA, conn);

            cmd.Parameters.Add("$Question", DbType.String).Value = newPwdQuestion;
            cmd.Parameters.Add("$Answer", DbType.String).Value = EncodePassword(newPwdAnswer);
            cmd.Parameters.Add("$Username", DbType.String).Value = username;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;


            int rowsAffected = 0;

            try
            {
                conn.Open();

                rowsAffected = cmd.ExecuteNonQuery();
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "ChangePasswordQuestionAndAnswer", WriteExceptionsToEventLog);
            }
            finally
            {
                conn.Close();
            }

            if (rowsAffected > 0)
            {
                return true;
            }

            return false;
        }
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            ValidatePasswordEventArgs args =
              new ValidatePasswordEventArgs(username, password, true);

            OnValidatingPassword(args);

            if (args.Cancel)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }



            if (RequiresUniqueEmail && GetUserNameByEmail(email) != "")
            {
                status = MembershipCreateStatus.DuplicateEmail;
                return null;
            }

            MembershipUser u = GetUser(username, false);

            if (u == null)
            {
                DateTime createDate = DateTime.Now;

                if (providerUserKey != null)
                {
                    status = MembershipCreateStatus.InvalidProviderUserKey;
                    return null;
                }

                SQLiteConnection conn = new SQLiteConnection(connectionString);
                SQLiteCommand cmd = new SQLiteCommand(MembershipSql.CreateUser, conn);

                cmd.Parameters.Add("$Username", DbType.String).Value = username;
                cmd.Parameters.Add("$Password", DbType.String).Value = EncodePassword(password);
                cmd.Parameters.Add("$Email", DbType.String).Value = email;
                cmd.Parameters.Add("$PasswordQuestion", DbType.String).Value = passwordQuestion;
                cmd.Parameters.Add("$PasswordAnswer", DbType.String).Value = EncodePassword(passwordAnswer);
                cmd.Parameters.Add("$IsApproved", DbType.Boolean).Value = isApproved;
                cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;
                cmd.Parameters.Add("$IsLockedOut", DbType.Boolean).Value = false;

                try
                {
                    conn.Open();

                    int recAdded = cmd.ExecuteNonQuery();

                    if (recAdded > 0)
                    {
                        status = MembershipCreateStatus.Success;
                    }
                    else
                    {
                        status = MembershipCreateStatus.UserRejected;
                    }
                }
                catch (SQLiteException e)
                {
                    try
                    {
                        ProviderUtility.HandleException(e, eventSource, "CreateUser", WriteExceptionsToEventLog);
                    }
                    catch { }


                    status = MembershipCreateStatus.ProviderError;
                }
                finally
                {
                    conn.Close();
                }


                return GetUser(username, false);
            }
            else
            {
                status = MembershipCreateStatus.DuplicateUserName;
            }


            return null;
        }
        public override bool DeleteUser(string username, bool deleteAllRelatedData)
        {
            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(MembershipSql.DeleteUser , conn);

            cmd.Parameters.Add("$Username", DbType.String).Value = username;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            int rowsAffected = 0;

            try
            {
                if (deleteAllRelatedData)
                {
                    Roles.RemoveUserFromRoles(username, Roles.GetRolesForUser(username));
                    
                    // Process commands to delete all data for the user in the database.
                }
                conn.Open();
                rowsAffected = cmd.ExecuteNonQuery();


            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "DeleteUser", WriteExceptionsToEventLog);
                    
            }
            finally
            {
                conn.Close();
            }

            if (rowsAffected > 0)
                return true;

            return false;
        }
        public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(MembershipSql.GetAppUsers, conn);
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;
            cmd.Parameters.Add("$Count", DbType.Int32).Value = pageSize;
            cmd.Parameters.Add("$Skip", DbType.Int32).Value = pageSize * pageIndex;
            MembershipUserCollection users = new MembershipUserCollection();
            SQLiteDataReader r = null;

            int recordCount = 0;

            try
            {
                conn.Open();
                r = cmd.ExecuteReader();
                while (r.Read())
                {
                    users.Add(this.GetUserFromReader(r));
                    recordCount++;
                }
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "GetAllUsers", WriteExceptionsToEventLog);
                
            }
            finally
            {
                totalRecords = recordCount;
                if (r != null) { r.Close(); }

                conn.Close();
            }
            return users;
        }
        public override int GetNumberOfUsersOnline()
        {
            TimeSpan onlineSpan = new TimeSpan(0, System.Web.Security.Membership.UserIsOnlineTimeWindow, 0);
            DateTime compareTime = DateTime.Now.Subtract(onlineSpan);

            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(MembershipSql.GetUsersOnline , conn);

            cmd.Parameters.Add("$CompareDate", DbType.DateTime).Value = compareTime;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            int numOnline = 0;

            try
            {
                conn.Open();

                numOnline = (int)cmd.ExecuteScalar();
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "GetNumberOfUsersOnline", WriteExceptionsToEventLog);
                    
            }
            finally
            {
                conn.Close();
            }

            return numOnline;
        }
        public override string GetPassword(string username, string answer)
        {
            if (!EnablePasswordRetrieval)
            {
                throw new ProviderException("Password Retrieval Not Enabled.");
            }

            if (PasswordFormat == MembershipPasswordFormat.Hashed)
            {
                throw new ProviderException("Cannot retrieve Hashed passwords.");
            }

            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(MembershipSql.GetPassword , conn);

            cmd.Parameters.Add("$Username", DbType.String).Value = username;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            string password = "";
            string passwordAnswer = "";
            SQLiteDataReader reader = null;

            try
            {
                conn.Open();

                reader = cmd.ExecuteReader(CommandBehavior.SingleRow);

                if (reader.HasRows)
                {
                    reader.Read();

                    if (reader.GetBoolean(2))
                        throw new MembershipPasswordException("The supplied user is locked out.");

                    password = reader.GetString(0);
                    passwordAnswer = reader.GetString(1);
                }
                else
                {
                    throw new MembershipPasswordException("The supplied user name is not found.");
                }
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "GetPassword", WriteExceptionsToEventLog);
                    
            }
            finally
            {
                if (reader != null) { reader.Close(); }
                conn.Close();
            }


            if (RequiresQuestionAndAnswer && !CheckPassword(answer, passwordAnswer))
            {
                UpdateFailureCount(username, "passwordAnswer");

                throw new MembershipPasswordException("Incorrect password answer.");
            }


            if (PasswordFormat == MembershipPasswordFormat.Encrypted)
            {
                password = UnEncodePassword(password);
            }

            return password;
        }
        public override MembershipUser GetUser(string username, bool userIsOnline)
        {
            SQLiteConnection conn = new SQLiteConnection(connectionString);

            string sql = "Select Count(*) from User where Username = $Username AND AppID = $AppID;";
            SQLiteCommand userExistsCmd = new SQLiteCommand(sql,conn );
            SQLiteCommand cmd = new SQLiteCommand(MembershipSql.GetUserByName , conn);
            SQLiteCommand updateCmd = new SQLiteCommand(MembershipSql.UpdateUserAccessTimeByName, conn);

            userExistsCmd.Parameters.Add("$Username", DbType.String).Value = username;
            userExistsCmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            updateCmd.Parameters.Add("$Username", DbType.String).Value = username;
            updateCmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;
            
            cmd.Parameters.Add("$Username", DbType.String).Value = username;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            MembershipUser u = null;
            SQLiteDataReader reader = null;

            try
            {
                conn.Open();

                Object o = userExistsCmd.ExecuteScalar();

                long count = (o == DBNull.Value ? 0 : (long)o);


                reader = cmd.ExecuteReader();
                reader.Read();
                if (count != 0)
                {
                    u = GetUserFromReader(reader);

                    if (userIsOnline)
                    {
                        updateCmd.ExecuteNonQuery();
                    }
                }

            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "GetUser(String, Boolean)", WriteExceptionsToEventLog);

                    
            }
            finally
            {
                if (reader != null) { reader.Close(); }

                conn.Close();
            }

            return u;
        }
        public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
        {
            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(MembershipSql.GetUserByID , conn);
            SQLiteCommand updateCmd = new SQLiteCommand(MembershipSql.UpdateAccessTimeByID, conn);


            updateCmd.Parameters.Add("$UserID", DbType.Int64).Value = providerUserKey;
            cmd.Parameters.Add("$UserID", DbType.Int64).Value = providerUserKey;

            MembershipUser u = null;
            SQLiteDataReader reader = null;

            try
            {
                conn.Open();

                reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    reader.Read();
                    u = GetUserFromReader(reader);

                    if (userIsOnline)
                    {

                        updateCmd.ExecuteNonQuery();
                    }
                }

            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "GetUser(Object, Boolean)", WriteExceptionsToEventLog);

                    

            }
            finally
            {
                if (reader != null) { reader.Close(); }

                conn.Close();
            }

            return u;
        }
        private MembershipUser GetUserFromReader(SQLiteDataReader reader)
        {
            object providerUserKey = reader.GetValue(0);
            string username = reader.GetString(1);
            string email = reader.GetString(2);
            string passwordQuestion = (reader.GetValue(3) != DBNull.Value ? reader.GetString(3) : "");
            string comment = (reader.GetValue(4) != DBNull.Value ? reader.GetString(4) : "");
            bool isApproved = reader.GetBoolean(5);
            bool isLockedOut = reader.GetBoolean(6);
            DateTime creationDate = reader.GetDateTime(7);
            DateTime lastLoginDate = (reader.GetValue(8) != DBNull.Value ? reader.GetDateTime(8) : new DateTime() );
            DateTime lastActivityDate = reader.GetDateTime(9);
            DateTime lastPasswordChangedDate = reader.GetDateTime(10);
            DateTime lastLockedOutDate = (reader.GetValue(11) != DBNull.Value ? reader.GetDateTime(11) : new DateTime() );
            
            MembershipUser u = new MembershipUser(this.Name,
                                                  username,
                                                  providerUserKey,
                                                  email,
                                                  passwordQuestion,
                                                  comment,
                                                  isApproved,
                                                  isLockedOut,
                                                  creationDate,
                                                  lastLoginDate,
                                                  lastActivityDate,
                                                  lastPasswordChangedDate,
                                                  lastLockedOutDate);

            return u;
        }
        public override bool UnlockUser(string username)
        {
            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(MembershipSql.UnlockUser , conn);

            
            cmd.Parameters.Add("$Username", DbType.String).Value = username;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            int rowsAffected = 0;

            try
            {
                conn.Open();

                rowsAffected = cmd.ExecuteNonQuery();
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "UnlockUser", WriteExceptionsToEventLog);
                    
            }
            finally
            {
                conn.Close();
            }

            if (rowsAffected > 0)
                return true;

            return false;
        }
        public override string GetUserNameByEmail(string email)
        {
            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(MembershipSql.GetUserNameByEmail , conn);

            cmd.Parameters.Add("$Email", DbType.String).Value = email;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            string username = "";

            try
            {
                conn.Open();
                Object o = cmd.ExecuteScalar();
                username = (o == DBNull.Value ? "" : (string)o);
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "GetUserNameByEmail", WriteExceptionsToEventLog);
                    
            }
            finally
            {
                conn.Close();
            }

            if (username == null)
                username = "";

            return username;
        }
        public override string ResetPassword(string username, string answer)
        {
            if (!EnablePasswordReset)
            {
                throw new NotSupportedException("Password reset is not enabled.");
            }

            if (answer == null && RequiresQuestionAndAnswer)
            {
                UpdateFailureCount(username, "passwordAnswer");

                throw new ProviderException("Password answer required for password reset.");
            }

            string newPassword =
              System.Web.Security.Membership.GeneratePassword(newPasswordLength, MinRequiredNonAlphanumericCharacters);


            ValidatePasswordEventArgs args =
              new ValidatePasswordEventArgs(username, newPassword, true);

            OnValidatingPassword(args);

            if (args.Cancel)
                if (args.FailureInformation != null)
                    throw args.FailureInformation;
                else
                    throw new MembershipPasswordException("Reset password canceled due to password validation failure.");


            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(MembershipSql.QueryPasswordReset , conn);
            SQLiteCommand updateCmd = new SQLiteCommand(MembershipSql.ResetPassword, conn);


            cmd.Parameters.Add("$Username", DbType.String).Value = username;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            updateCmd.Parameters.Add("$Password", DbType.String).Value = EncodePassword(newPassword);
            updateCmd.Parameters.Add("$Username", DbType.String).Value = username;
            updateCmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;


            int rowsAffected = 0;
            string passwordAnswer = "";
            SQLiteDataReader reader = null;

            try
            {
                conn.Open();

                reader = cmd.ExecuteReader(CommandBehavior.SingleRow);

                if (reader.HasRows)
                {
                    reader.Read();

                    if (reader.GetBoolean(1))
                        throw new MembershipPasswordException("The supplied user is locked out.");

                    passwordAnswer = reader.GetString(0);
                }
                else
                {
                    throw new MembershipPasswordException("The supplied user name is not found.");
                }

                if (RequiresQuestionAndAnswer && !CheckPassword(answer, passwordAnswer))
                {
                    UpdateFailureCount(username, "passwordAnswer");

                    throw new MembershipPasswordException("Incorrect password answer.");
                }

                rowsAffected = updateCmd.ExecuteNonQuery();
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "ResetPassword", WriteExceptionsToEventLog);

            }
            finally
            {
                if (reader != null) { reader.Close(); }
                conn.Close();
            }

            if (rowsAffected > 0)
            {
                return newPassword;
            }
            else
            {
                throw new MembershipPasswordException("User not found, or user is locked out. Password not Reset.");
            }
        }
        public override void UpdateUser(MembershipUser user)
        {
            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(MembershipSql.UpdateUser, conn);

            cmd.Parameters.Add("$Email", DbType.String).Value = user.Email;
            cmd.Parameters.Add("$Comment", DbType.String).Value = user.Comment;
            cmd.Parameters.Add("$IsApproved", DbType.Boolean).Value = user.IsApproved;
            cmd.Parameters.Add("$Username", DbType.String).Value = user.UserName;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;


            try
            {
                conn.Open();

                cmd.ExecuteNonQuery();
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "UpdateUser", WriteExceptionsToEventLog);
                
            }
            finally
            {
                conn.Close();
            }
        }
        public override bool ValidateUser(string username, string password)
        {
            bool isValid = false;

            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(MembershipSql.ValidateUser , conn);
            SQLiteCommand updateCmd = new SQLiteCommand(MembershipSql.UpdateLastLoginDate, conn);


            updateCmd.Parameters.Add("$Username", DbType.String).Value = username;
            updateCmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID; 

            cmd.Parameters.Add("$Username", DbType.String).Value = username;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            SQLiteDataReader reader = null;
            bool isApproved = false;
            string pwd = "";

            try
            {
                conn.Open();

                reader = cmd.ExecuteReader(CommandBehavior.SingleRow);

                if (reader.HasRows)
                {
                    reader.Read();
                    pwd = reader.GetString(0);
                    isApproved = reader.GetBoolean(1);
                }
                else
                {
                    return false;
                }

                reader.Close();

                if (CheckPassword(password, pwd))
                {
                    if (isApproved)
                    {
                        isValid = true;
                        updateCmd.ExecuteNonQuery();
                    }
                }
                else
                {
                    conn.Close();

                    UpdateFailureCount(username, "password");
                }
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "ValidateUser", WriteExceptionsToEventLog);
                    
            }
            finally
            {
                if (reader != null) { reader.Close(); }
                conn.Close();
            }

            return isValid;
        }
        private void UpdateFailureCount(string username, string failureType)
        {
            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand queryCmd = new SQLiteCommand(MembershipSql.QueryFailureCount , conn);
            SQLiteCommand updateCmd = new SQLiteCommand();
            SQLiteCommand lockoutCmd = new SQLiteCommand(MembershipSql.LockOutUser, conn);


            updateCmd.Connection = conn;
            updateCmd.Parameters.Add("$Username", DbType.String).Value = username;
            updateCmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;
            updateCmd.Parameters.Add("$Count", DbType.Int32);

            queryCmd.Parameters.Add("$Username", DbType.String).Value = username;
            queryCmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;
            
            lockoutCmd.Parameters.Add("$IsLockedOut", DbType.Boolean).Value = true;
            lockoutCmd.Parameters.Add("$Username", DbType.String).Value = username;
            lockoutCmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            SQLiteDataReader reader = null;
            DateTime windowStart = new DateTime();
            int failureCount = 0;

            try
            {
                conn.Open();

                reader = queryCmd.ExecuteReader(CommandBehavior.SingleRow);

                if (reader.HasRows)
                {
                    reader.Read();

                    if (failureType == "password")
                    {
                        failureCount = reader.GetInt32(0);
                        windowStart = reader.GetDateTime(1);
                    }

                    if (failureType == "passwordAnswer")
                    {
                        failureCount = reader.GetInt32(2);
                        windowStart = reader.GetDateTime(3);
                    }
                }

                reader.Close();

                DateTime windowEnd = windowStart.AddMinutes(PasswordAttemptWindow);

                if (failureCount == 0 || DateTime.Now > windowEnd)
                {
                    // First password failure or outside of PasswordAttemptWindow. 
                    // Start a new password failure count from 1 and a new window starting now.

                    if (failureType == "password")
                        updateCmd.CommandText = MembershipSql.UpdatePasswordFailureCountStart;

                    if (failureType == "passwordAnswer")
                        updateCmd.CommandText = MembershipSql.UpdateAnswerFailureCountStart;

                    updateCmd.Parameters["$Count"].Value = 1;

                    if (updateCmd.ExecuteNonQuery() < 0)
                        throw new ProviderException("Unable to update failure count and window start.");
                }
                else
                {
                    if (failureCount++ >= MaxInvalidPasswordAttempts)
                    {

                        if (lockoutCmd.ExecuteNonQuery() < 0)
                            throw new ProviderException("Unable to lock out user.");
                    }
                    else
                    {
                        // Password attempts have not exceeded the failure threshold. Update
                        // the failure counts. Leave the window the same.

                        if (failureType == "password")
                            updateCmd.CommandText = MembershipSql.UpdatePasswordFailureCount;

                        if (failureType == "passwordAnswer")
                            updateCmd.CommandText = MembershipSql.UpdateAnswerFailureCount;

                        updateCmd.Parameters["$Count"].Value = failureCount;


                        if (updateCmd.ExecuteNonQuery() < 0)
                            throw new ProviderException("Unable to update failure count.");
                    }
                }
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "UpdateFailureCount", WriteExceptionsToEventLog);

                    
            }
            finally
            {
                if (reader != null) { reader.Close(); }
                conn.Close();
            }
        }
        public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
        {

            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(MembershipSql.FindUsersByName, conn);

            MembershipUserCollection users = new MembershipUserCollection();
            SQLiteDataReader r = null;
            cmd.Parameters.Add("$UsernameSearch", DbType.String).Value = usernameToMatch;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;
            cmd.Parameters.Add("$Count", DbType.Int32).Value = pageSize;
            cmd.Parameters.Add("$Skip", DbType.Int32).Value = pageIndex * pageSize;

            int recordCount = 0;

            try
            {
                conn.Open();
                r = cmd.ExecuteReader();
                while (r.Read())
                {
                    users.Add(this.GetUserFromReader(r));
                    recordCount++;
                }
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "FindUsersByName", WriteExceptionsToEventLog);
                
            }
            finally
            {
                totalRecords = recordCount;
                if (r != null) { r.Close(); }

                conn.Close();
            }
            return users;
        }
        public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
        {

            
            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(MembershipSql.FindUsersByEmail, conn);

            MembershipUserCollection users = new MembershipUserCollection();
            SQLiteDataReader r = null;
            cmd.Parameters.Add("$EmailSearch", DbType.String).Value = emailToMatch;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;
            cmd.Parameters.Add("$Count", DbType.Int32).Value = pageSize;
            cmd.Parameters.Add("$Skip", DbType.Int32).Value = pageIndex * pageSize;

            int recordCount = 0;

            try
            {
                conn.Open();
                r = cmd.ExecuteReader();
                while (r.Read())
                {
                    users.Add(this.GetUserFromReader(r));
                    recordCount++;
                }
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "FindUsersByEmail", WriteExceptionsToEventLog);
                
            }
            finally
            {
                totalRecords = recordCount;
                if (r != null) { r.Close(); }

                conn.Close();
            }
            return users;


        }



    }
}

Added Membership/MembershipProvider/MembershipUtility.cs.































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
using System.Web.Security;
using System.Configuration.Provider;
using System.Collections.Specialized;
using System;
using System.Data;
using System.Data.SQLite;
using System.Configuration;
using System.Diagnostics;
using System.Web;
using System.Globalization;
using System.Security.Cryptography;
using System.Text;
using System.Web.Configuration;




namespace SQLiteProvider
{

    public sealed partial class SQLiteMembershipProvider : MembershipProvider
    {
        //
        // CheckPassword
        //   Compares password values based on the MembershipPasswordFormat.
        //

        private bool CheckPassword(string password, string dbpassword)
        {
            string pass1 = password;
            string pass2 = dbpassword;

            switch (PasswordFormat)
            {
                case MembershipPasswordFormat.Encrypted:
                    pass2 = UnEncodePassword(dbpassword);
                    break;
                case MembershipPasswordFormat.Hashed:
                    pass1 = EncodePassword(password);
                    break;
                default:
                    break;
            }

            if (pass1 == pass2)
            {
                return true;
            }

            return false;
        }


        //
        // EncodePassword
        //   Encrypts, Hashes, or leaves the password clear based on the PasswordFormat.
        //

        private string EncodePassword(string password)
        {
            string pw = (password == null ? "" : password);
            string encodedPassword = pw;

            switch (PasswordFormat)
            {
                case MembershipPasswordFormat.Clear:
                    break;
                case MembershipPasswordFormat.Encrypted:
                    encodedPassword =
                      Convert.ToBase64String(EncryptPassword(Encoding.Unicode.GetBytes(pw)));
                    break;
                case MembershipPasswordFormat.Hashed:
                    HMACSHA1 hash = new HMACSHA1();
                    hash.Key = HexToByte(machineKey.ValidationKey);
                    encodedPassword =
                      Convert.ToBase64String(hash.ComputeHash(Encoding.Unicode.GetBytes(pw)));
                    break;
                default:
                    throw new ProviderException("Unsupported password format.");
            }

            return encodedPassword;
        }


        //
        // UnEncodePassword
        //   Decrypts or leaves the password clear based on the PasswordFormat.
        //

        private string UnEncodePassword(string encodedPassword)
        {
            string password = encodedPassword;

            switch (PasswordFormat)
            {
                case MembershipPasswordFormat.Clear:
                    break;
                case MembershipPasswordFormat.Encrypted:
                    password =
                      Encoding.Unicode.GetString(DecryptPassword(Convert.FromBase64String(password)));
                    break;
                case MembershipPasswordFormat.Hashed:
                    throw new ProviderException("Cannot unencode a hashed password.");
                default:
                    throw new ProviderException("Unsupported password format.");
            }

            return password;
        }

        //
        // HexToByte
        //   Converts a hexadecimal string to a byte array. Used to convert encryption
        // key values from the configuration.
        //

        private byte[] HexToByte(string hexString)
        {
            byte[] returnBytes = new byte[hexString.Length / 2];
            for (int i = 0; i < returnBytes.Length; i++)
                returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16);
            return returnBytes;
        }

    }
}

Added Membership/MembershipProvider/ProviderProperties.cs.





























































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System.Web.Security;
using System.Configuration.Provider;
using System.Collections.Specialized;
using System;
using System.Data;
using System.Data.SQLite;
using System.Configuration;
using System.Diagnostics;
using System.Web;
using System.Globalization;
using System.Security.Cryptography;
using System.Text;
using System.Web.Configuration;




namespace SQLiteProvider
{

    public sealed partial class SQLiteMembershipProvider : MembershipProvider
    {
        public override string ApplicationName
        {
            get { return _ApplicationName; }
            set
            {
                _ApplicationName = value;
                _AppID = ProviderUtility.GetApplicationID(connectionString, value);
            }
        }
        public override bool EnablePasswordReset
        {
            get { return _EnablePasswordReset; }
        }


        public override bool EnablePasswordRetrieval
        {
            get { return _EnablePasswordRetrieval; }
        }


        public override bool RequiresQuestionAndAnswer
        {
            get { return _RequiresQuestionAndAnswer; }
        }


        public override bool RequiresUniqueEmail
        {
            get { return _RequiresUniqueEmail; }
        }


        public override int MaxInvalidPasswordAttempts
        {
            get { return _MaxInvalidPasswordAttempts; }
        }


        public override int PasswordAttemptWindow
        {
            get { return _PasswordAttemptWindow; }
        }


        public override MembershipPasswordFormat PasswordFormat
        {
            get { return _PasswordFormat; }
        }

        private int _MinRequiredNonAlphanumericCharacters;

        public override int MinRequiredNonAlphanumericCharacters
        {
            get { return _MinRequiredNonAlphanumericCharacters; }
        }

        private int _MinRequiredPasswordLength;

        public override int MinRequiredPasswordLength
        {
            get { return _MinRequiredPasswordLength; }
        }

        private string _PasswordStrengthRegularExpression;

        public override string PasswordStrengthRegularExpression
        {
            get { return _PasswordStrengthRegularExpression; }
        }
    }
}

Added Membership/Properties/AssemblyInfo.cs.







































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following 
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SQLiteProvider")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Fresnel Computing")]
[assembly: AssemblyProduct("SQLiteProvider")]
[assembly: AssemblyCopyright("Copyright © Fresnel Computing 2006")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("08669110-651d-458d-8c01-0bf683bbe931")]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Revision and Build Numbers 
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Added Membership/Properties/Settings.Designer.cs.





















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.42
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace SQLiteProvider.Properties {
    
    
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
        
        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
        
        public static Settings Default {
            get {
                return defaultInstance;
            }
        }
    }
}

Added Membership/Properties/Settings.settings.











>
>
>
>
>
1
2
3
4
5
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
  <Profiles />
  <Settings />
</SettingsFile>

Added Membership/RoleProvider/RoleProvider.cs.







































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
using System.Web.Security;
using System.Configuration.Provider;
using System.Collections.Specialized;
using System.Collections.Generic;
using System;
using System.Data;
using System.Data.SQLite;
using System.Configuration;
using System.Diagnostics;
using System.Web;
using System.Globalization;



namespace SQLiteProvider
{

    public sealed partial class SQLiteRoleProvider : RoleProvider
    {


        private string eventSource = "SQLiteRoleProvider";

        private string connectionString;


        private bool _WriteExceptionsToEventLog = false;
        private string _ApplicationName;
        private long _AppID;

        public bool WriteExceptionsToEventLog
        {
            get { return _WriteExceptionsToEventLog; }
            set { _WriteExceptionsToEventLog = value; }
        }



        //
        // System.Configuration.Provider.ProviderBase.Initialize Method
        //

        public override void Initialize(string name, NameValueCollection config)
        {

            //
            // Initialize values from web.config.
            //

            if (config == null)
                throw new ArgumentNullException("config");

            if (name == null || name.Length == 0)
                name = "SQLiteRoleProvider";

            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "SQLite Role Privider");
            }

            // Initialize the abstract base class.
            base.Initialize(name, config);




            _WriteExceptionsToEventLog = ProviderUtility.GetExceptionDesitination(config["writeExceptionsToEventLog"]);
            connectionString = ProviderUtility.GetConnectionString(config["connectionStringName"]);
            ApplicationName = ProviderUtility.GetApplicationName(config["applicationName"]);

        }



        //
        // System.Web.Security.RoleProvider properties.
        //





        public override string ApplicationName
        {
            get { return _ApplicationName; }
            set
            {
                _ApplicationName = value;
                _AppID = ProviderUtility.GetApplicationID(connectionString, value);
            }
        }

        //
        // System.Web.Security.RoleProvider methods.
        //

        //
        // RoleProvider.AddUsersToRoles
        //

        public override void AddUsersToRoles(string[] usernames, string[] rolenames)
        {
            foreach (string rolename in rolenames)
            {
                if (!RoleExists(rolename))
                {
                    throw new ProviderException("Role name not found.");
                }
            }

            foreach (string username in usernames)
            {
                if (username.IndexOf(',') > 0)
                {
                    throw new ArgumentException("User names cannot contain commas.");
                }

                foreach (string rolename in rolenames)
                {
                    if (IsUserInRole(username, rolename))
                    {
                        throw new ProviderException("User is already in role.");
                    }
                }
            }


            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(RoleSql.AddUserToRole, conn);

            SQLiteParameter userParm = cmd.Parameters.Add("$Username", DbType.String);
            SQLiteParameter roleParm = cmd.Parameters.Add("$Rolename", DbType.String);
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            SQLiteTransaction tran = null;

            try
            {
                conn.Open();
                tran = conn.BeginTransaction();
                cmd.Transaction = tran;

                foreach (string username in usernames)
                {
                    foreach (string rolename in rolenames)
                    {
                        userParm.Value = username;
                        roleParm.Value = rolename;
                        cmd.ExecuteNonQuery();
                    }
                }

                tran.Commit();
            }
            catch (SQLiteException e)
            {
                try
                {
                    tran.Rollback();
                }
                catch { }

                ProviderUtility.HandleException(e, eventSource, "AddUsersToRoles", WriteExceptionsToEventLog);

            }
            finally
            {
                conn.Close();
            }
        }


        //
        // RoleProvider.CreateRole
        //

        public override void CreateRole(string rolename)
        {
            if (rolename.IndexOf(',') > 0)
            {
                throw new ArgumentException("Role names cannot contain commas.");
            }

            if (RoleExists(rolename))
            {
                throw new ProviderException("Role name already exists.");
            }

            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(RoleSql.CreateRole, conn);

            cmd.Parameters.Add("$Rolename", DbType.String).Value = rolename;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            try
            {
                conn.Open();

                cmd.ExecuteNonQuery();
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "CreateRole", WriteExceptionsToEventLog);

            }
            finally
            {
                conn.Close();
            }
        }


        //
        // RoleProvider.DeleteRole
        //

        public override bool DeleteRole(string rolename, bool throwOnPopulatedRole)
        {
            if (!RoleExists(rolename))
            {
                throw new ProviderException("Role does not exist.");
            }

            if (throwOnPopulatedRole && GetUsersInRole(rolename).Length > 0)
            {
                throw new ProviderException("Cannot delete a populated role.");
            }

            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(RoleSql.DeleteRole, conn);

            cmd.Parameters.Add("$Rolename", DbType.String).Value = rolename;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;


            SQLiteCommand cmd2 = new SQLiteCommand(RoleSql.DeleteRoleFromMap, conn);

            cmd2.Parameters.Add("$Rolename", DbType.String).Value = rolename;
            cmd2.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            SQLiteTransaction tran = null;

            try
            {
                conn.Open();
                tran = conn.BeginTransaction();
                cmd.Transaction = tran;
                cmd2.Transaction = tran;

                cmd2.ExecuteNonQuery();
                cmd.ExecuteNonQuery();

                tran.Commit();
            }
            catch (SQLiteException e)
            {
                try
                {
                    tran.Rollback();
                }
                catch { }

                ProviderUtility.HandleException(e, eventSource, "DeleteRole", WriteExceptionsToEventLog);
            }
            finally
            {
                conn.Close();
            }

            return true;
        }


        //
        // RoleProvider.GetAllRoles
        //

        public override string[] GetAllRoles()
        {
            List<String> names = new List<string>();
            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(RoleSql.GetAllRoles, conn);

            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            SQLiteDataReader reader = null;

            try
            {
                conn.Open();

                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    names.Add(reader.GetString(0));
                }
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "GetAllRoles", WriteExceptionsToEventLog);
            }
            finally
            {
                if (reader != null) { reader.Close(); }
                conn.Close();
            }


            return names.ToArray();
        }


        //
        // RoleProvider.GetRolesForUser
        //

        public override string[] GetRolesForUser(string username)
        {
            List<string> roles = new List<string>();

            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(RoleSql.GetRolesForUser, conn);

            cmd.Parameters.Add("$Username", DbType.String).Value = username;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            SQLiteDataReader reader = null;

            try
            {
                conn.Open();

                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    roles.Add(reader.GetString(0));
                }
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "GetRolesForUser", WriteExceptionsToEventLog);
            }
            finally
            {
                if (reader != null) { reader.Close(); }
                conn.Close();
            }


            return roles.ToArray();
        }


        //
        // RoleProvider.GetUsersInRole
        //

        public override string[] GetUsersInRole(string rolename)
        {
            List<String> users = new List<string>();

            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(RoleSql.GetUsersInRole, conn);

            cmd.Parameters.Add("$Rolename", DbType.String).Value = rolename;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            SQLiteDataReader reader = null;

            try
            {
                conn.Open();

                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    users.Add(reader.GetString(0));
                }
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "GetUsersInRole", WriteExceptionsToEventLog);
            }
            finally
            {
                if (reader != null) { reader.Close(); }
                conn.Close();
            }
            return users.ToArray();
        }


        //
        // RoleProvider.IsUserInRole
        //

        public override bool IsUserInRole(string username, string rolename)
        {
            long count = 0;

            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(RoleSql.IsUserInRole, conn);

            cmd.Parameters.Add("$Username", DbType.String).Value = username;
            cmd.Parameters.Add("$Rolename", DbType.String).Value = rolename;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            try
            {
                conn.Open();
                count = (long)cmd.ExecuteScalar();
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "IsUserInRole", WriteExceptionsToEventLog);
            }
            finally
            {
                conn.Close();
            }

            return (count != 0);
        }


        //
        // RoleProvider.RemoveUsersFromRoles
        //

        public override void RemoveUsersFromRoles(string[] usernames, string[] rolenames)
        {
            foreach (string rolename in rolenames)
            {
                if (!RoleExists(rolename))
                {
                    throw new ProviderException("Role name not found.");
                }
            }

            foreach (string username in usernames)
            {
                foreach (string rolename in rolenames)
                {
                    if (!IsUserInRole(username, rolename))
                    {
                        throw new ProviderException("User is not in role.");
                    }
                }
            }


            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(RoleSql.DeleteUserFromRole, conn);

            SQLiteParameter userParm = cmd.Parameters.Add("$Username", DbType.String);
            SQLiteParameter roleParm = cmd.Parameters.Add("$Rolename", DbType.String);
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            SQLiteTransaction tran = null;

            try
            {
                conn.Open();
                tran = conn.BeginTransaction();
                cmd.Transaction = tran;

                foreach (string username in usernames)
                {
                    foreach (string rolename in rolenames)
                    {
                        userParm.Value = username;
                        roleParm.Value = rolename;
                        cmd.ExecuteNonQuery();
                    }
                }

                tran.Commit();
            }
            catch (SQLiteException e)
            {
                try
                {
                    tran.Rollback();
                }
                catch { }
                ProviderUtility.HandleException(e, eventSource, "RemoveUsersFromRoles", WriteExceptionsToEventLog);

            }
            finally
            {
                conn.Close();
            }
        }


        //
        // RoleProvider.RoleExists
        //

        public override bool RoleExists(string rolename)
        {
            long count = 0;

            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(RoleSql.RoleExists, conn);

            cmd.Parameters.Add("$Rolename", DbType.String).Value = rolename;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            try
            {
                conn.Open();
                count = (long)cmd.ExecuteScalar();
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "RoleExists", WriteExceptionsToEventLog);


            }
            finally
            {
                conn.Close();
            }

            return (count != 0);
        }

        //
        // RoleProvider.FindUsersInRole
        //

        public override string[] FindUsersInRole(string rolename, string usernameToMatch)
        {
            SQLiteConnection conn = new SQLiteConnection(connectionString);
            SQLiteCommand cmd = new SQLiteCommand(RoleSql.FindUsersInRole, conn);
            cmd.Parameters.Add("$Username", DbType.String).Value = usernameToMatch;
            cmd.Parameters.Add("$Rolename", DbType.String).Value = rolename;
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

            List<String> users = new List<string>();
            SQLiteDataReader reader = null;

            try
            {
                conn.Open();

                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    users.Add(reader.GetString(0));
                }
            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, eventSource, "FindUsersInRole", WriteExceptionsToEventLog);                

            }
            finally
            {
                if (reader != null) { reader.Close(); }

                conn.Close();
            }

            return users.ToArray();
        }



    }
}


Added Membership/SQLiteProvider.csproj.















































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>8.0.50727</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{1B7C6ACE-35AA-481C-9CF6-56B702E3E043}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>SQLiteProvider</RootNamespace>
    <AssemblyName>SQLiteProvider</AssemblyName>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.configuration" />
    <Reference Include="System.Data" />
    <Reference Include="System.Data.SQLite" />
    <Reference Include="System.Web" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Properties\Settings.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
      <DependentUpon>Settings.settings</DependentUpon>
    </Compile>
    <Compile Include="SiteMap\SQLiteSiteMap.cs" />
    <Compile Include="Sql\ApplicationSql.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>ApplicationSql.resx</DependentUpon>
    </Compile>
    <Compile Include="Sql\MembershipSql.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>MembershipSql.resx</DependentUpon>
    </Compile>
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="Sql\RoleSql.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>RoleSql.resx</DependentUpon>
    </Compile>
    <Compile Include="MembershipProvider\Membership.cs" />
    <Compile Include="MembershipProvider\Initialize.cs" />
    <Compile Include="MembershipProvider\ProviderProperties.cs" />
    <Compile Include="MembershipProvider\MembershipUtility.cs" />
    <Compile Include="Sql\SiteMapSql.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>SiteMapSql.resx</DependentUpon>
      <CustomToolNamespace>SQLiteProvider</CustomToolNamespace>
    </Compile>
    <Compile Include="Utiliy\ProviderUtility.cs" />
    <Compile Include="RoleProvider\RoleProvider.cs" />
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="Sql\ApplicationSql.resx">
      <SubType>Designer</SubType>
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>ApplicationSql.Designer.cs</LastGenOutput>
      <CustomToolNamespace>SQLiteProvider</CustomToolNamespace>
    </EmbeddedResource>
    <EmbeddedResource Include="Sql\MembershipSql.resx">
      <SubType>Designer</SubType>
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>MembershipSql.Designer.cs</LastGenOutput>
      <CustomToolNamespace>SQLiteProvider</CustomToolNamespace>
    </EmbeddedResource>
    <EmbeddedResource Include="Sql\RoleSql.resx">
      <SubType>Designer</SubType>
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>RoleSql.Designer.cs</LastGenOutput>
      <CustomToolNamespace>SQLiteProvider</CustomToolNamespace>
    </EmbeddedResource>
    <EmbeddedResource Include="Sql\SiteMapSql.resx">
      <SubType>Designer</SubType>
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>SiteMapSql.Designer.cs</LastGenOutput>
      <CustomToolNamespace>SQLiteProvider</CustomToolNamespace>
    </EmbeddedResource>
  </ItemGroup>
  <ItemGroup>
    <None Include="app.config" />
    <None Include="Properties\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
    </None>
    <None Include="Sql\Schema.sql" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="TODO.txt" />
  </ItemGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

Added Membership/SQLiteProvider.sln.









































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C# Express 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLiteProvider", "SQLiteProvider.csproj", "{1B7C6ACE-35AA-481C-9CF6-56B702E3E043}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{1B7C6ACE-35AA-481C-9CF6-56B702E3E043}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{1B7C6ACE-35AA-481C-9CF6-56B702E3E043}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{1B7C6ACE-35AA-481C-9CF6-56B702E3E043}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{1B7C6ACE-35AA-481C-9CF6-56B702E3E043}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal

Added Membership/SQLiteProvider.suo.

cannot compute difference between binary files

Added Membership/SiteMap/SQLiteSiteMap.cs.









































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Web;
using System.Data;
using System.Data.SQLite;
using System.IO;

namespace SQLiteProvider
{
    class SQLiteSiteMapProvider : StaticSiteMapProvider
    {
        SiteMapNode _root;
        Dictionary<long, SiteMapNode> _nodes = new Dictionary<long, SiteMapNode>();
        #region CommonProviderComponents
        private string eventSource = "SQLiteSiteMapProvider";
        private string connectionString;

        private bool _WriteExceptionsToEventLog = false;
        public bool WriteExceptionsToEventLog
        {
            get { return _WriteExceptionsToEventLog; }
            set { _WriteExceptionsToEventLog = value; }
        }

        private string _ApplicationName;
        private long _AppID;
        public string ApplicationName
        {
            get { return _ApplicationName; }
            set
            {
                _ApplicationName = value;
                _AppID = ProviderUtility.GetApplicationID(connectionString, value);
            }
        }

        private bool _initialized = false;
        public virtual bool IsInitialized
        {
            get { return _initialized; }
        }
        #endregion

        public override void Initialize(string name, NameValueCollection config)
        {

            lock (this)
            {
                if (_initialized)
                    return;

                //
                // Initialize values from web.config.
                //

                if (config == null)
                    throw new ArgumentNullException("config");

                if (name == null || name.Length == 0)
                    name = "SQLiteSiteMapProvider";

                if (String.IsNullOrEmpty(config["description"]))
                {
                    config.Remove("description");
                    config.Add("description", "SQLite SiteMap Privider");
                }

                /*
                if (!String.IsNullOrEmpty(config["updateFileName"]))
                {
                    _validationFileName = HttpContext.Current.Server.MapPath(String.Format("~/App_Data/{0}", config["updateFileName"]));
                    if (!File.Exists(_validationFileName))
                    {
                        File.Create(_validationFileName).Close();
                    }
                    _validationDate = File.GetLastWriteTime(_validationFileName);

                    FileSystemWatcher watcher = new FileSystemWatcher();
                    watcher.Changed += new FileSystemEventHandler(this.OnSiteMapChanged);
                    watcher.EnableRaisingEvents = true;

                }*/
                // Initialize the abstract base class.
                base.Initialize(name, config);

                _WriteExceptionsToEventLog = ProviderUtility.GetExceptionDesitination(config["writeExceptionsToEventLog"]);
                connectionString = ProviderUtility.GetConnectionString(config["connectionStringName"]);
                ApplicationName = ProviderUtility.GetApplicationName(config["applicationName"]);

            }


        }

        public override SiteMapNode BuildSiteMap()
        {
            lock (this)
            {
                if (_root != null)
                    return _root;

                SQLiteConnection conn = new SQLiteConnection(connectionString);
                SQLiteCommand cmd = new SQLiteCommand(SiteMapSql.GetNodes, conn);
                cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;

                long ID;
                string title;
                string description;
                string url;
                long parent;

                SiteMapNode n = null;
                SiteMapNode parentNode = null;

                try
                {
                    conn.Open();
                    SQLiteDataReader r = cmd.ExecuteReader();
                    if (r.Read())
                    {
                        ID = r.GetInt64(0);
                        
                        title = r.IsDBNull(1) ? null : r.GetString(1).Trim();
                        description = r.IsDBNull(2) ? null : r.GetString(2).Trim();
                        url = r.IsDBNull(3) ? null : r.GetString(3).Trim();
                        _root = new SiteMapNode(this, ID.ToString(), url, title, description);
                        _root.Roles = GetNodeRoles(ID, conn);
                        base.AddNode(_root, null);
                        _nodes.Add(ID, _root);

                    }
                    while (r.Read())
                    {
                        ID = r.GetInt64(0);

                        title = r.IsDBNull(1) ? null : r.GetString(1).Trim();
                        description = r.IsDBNull(2) ? null : r.GetString(2).Trim();
                        url = r.IsDBNull(3) ? null : r.GetString(3).Trim();
                        parent = r.GetInt64(4);

                        parentNode = GetParent(parent);
                        n = new SiteMapNode(this, ID.ToString(), url, title, description);
                        n.Roles = GetNodeRoles(ID, conn);

                        base.AddNode(n, parentNode);
                        _nodes.Add(ID, n);
                    }

                }
                catch (Exception ex)
                {
                    ProviderUtility.HandleException(ex, eventSource, "BuildSiteMap", _WriteExceptionsToEventLog);
                }
                finally
                {
                    conn.Close();
                }
                return _root;
            }

        }

        protected override SiteMapNode GetRootNodeCore()
        {
            lock (this)
            {
                BuildSiteMap();
                return _root;
            }
        }

        private SiteMapNode GetParent(long pid)
        {
            if (!_nodes.ContainsKey(pid))
                throw new System.Configuration.Provider.ProviderException("Invalid Parent ID");
            return _nodes[pid];
        }

        private IList GetNodeRoles(long ID, SQLiteConnection conn)
        {
            SQLiteCommand cmd = new SQLiteCommand(SiteMapSql.GetNodeRoles, conn);
            cmd.Parameters.Add("$AppID", DbType.Int64).Value = _AppID;
            cmd.Parameters.Add("$NodeID", DbType.Int64).Value = ID;
            ArrayList result = new ArrayList();

            SQLiteDataReader r = cmd.ExecuteReader();
            while (r.Read())
            {
                result.Add(r.GetString(0));
            }
            return (IList)result;
        }
    }
}

Added Membership/Sql/ApplicationSql.Designer.cs.





















































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.42
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace SQLiteProvider {
    using System;
    
    
    /// <summary>
    ///   A strongly-typed resource class, for looking up localized strings, etc.
    /// </summary>
    // This class was auto-generated by the StronglyTypedResourceBuilder
    // class via a tool like ResGen or Visual Studio.
    // To add or remove a member, edit your .ResX file then rerun ResGen
    // with the /str option, or rebuild your VS project.
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    internal class ApplicationSql {
        
        private static global::System.Resources.ResourceManager resourceMan;
        
        private static global::System.Globalization.CultureInfo resourceCulture;
        
        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        internal ApplicationSql() {
        }
        
        /// <summary>
        ///   Returns the cached ResourceManager instance used by this class.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Resources.ResourceManager ResourceManager {
            get {
                if (object.ReferenceEquals(resourceMan, null)) {
                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SQLiteProvider.Sql.ApplicationSql", typeof(ApplicationSql).Assembly);
                    resourceMan = temp;
                }
                return resourceMan;
            }
        }
        
        /// <summary>
        ///   Overrides the current thread's CurrentUICulture property for all
        ///   resource lookups using this strongly typed resource class.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Globalization.CultureInfo Culture {
            get {
                return resourceCulture;
            }
            set {
                resourceCulture = value;
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Select Count(*) from Application where ApplicationName = $ApplicationName.
        /// </summary>
        internal static string AppExists {
            get {
                return ResourceManager.GetString("AppExists", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Select AppID from Application where ApplicationName = $ApplicationName;.
        /// </summary>
        internal static string GetAppID {
            get {
                return ResourceManager.GetString("GetAppID", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Insert into Application (ApplicationName) values ($ApplicationName).
        /// </summary>
        internal static string InsertApp {
            get {
                return ResourceManager.GetString("InsertApp", resourceCulture);
            }
        }
    }
}

Added Membership/Sql/ApplicationSql.resx.













































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?xml version="1.0" encoding="utf-8"?>
<root>
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <data name="AppExists" xml:space="preserve">
    <value>Select Count(*) from Application where ApplicationName = $ApplicationName</value>
  </data>
  <data name="GetAppID" xml:space="preserve">
    <value>Select AppID from Application where ApplicationName = $ApplicationName;</value>
  </data>
  <data name="InsertApp" xml:space="preserve">
    <value>Insert into Application (ApplicationName) values ($ApplicationName)</value>
  </data>
</root>

Added Membership/Sql/MembershipSql.Designer.cs.



























































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.42
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace SQLiteProvider {
    using System;
    
    
    /// <summary>
    ///   A strongly-typed resource class, for looking up localized strings, etc.
    /// </summary>
    // This class was auto-generated by the StronglyTypedResourceBuilder
    // class via a tool like ResGen or Visual Studio.
    // To add or remove a member, edit your .ResX file then rerun ResGen
    // with the /str option, or rebuild your VS project.
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    internal class MembershipSql {
        
        private static global::System.Resources.ResourceManager resourceMan;
        
        private static global::System.Globalization.CultureInfo resourceCulture;
        
        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        internal MembershipSql() {
        }
        
        /// <summary>
        ///   Returns the cached ResourceManager instance used by this class.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Resources.ResourceManager ResourceManager {
            get {
                if (object.ReferenceEquals(resourceMan, null)) {
                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SQLiteProvider.Sql.MembershipSql", typeof(MembershipSql).Assembly);
                    resourceMan = temp;
                }
                return resourceMan;
            }
        }
        
        /// <summary>
        ///   Overrides the current thread's CurrentUICulture property for all
        ///   resource lookups using this strongly typed resource class.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Globalization.CultureInfo Culture {
            get {
                return resourceCulture;
            }
            set {
                resourceCulture = value;
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to UPDATE User SET Password = $Password, LastPasswordChangedDate = datetime(&apos;now&apos;,&apos;utc&apos;) WHERE Username = $Username AND AppID = $AppID;.
        /// </summary>
        internal static string ChangePassword {
            get {
                return ResourceManager.GetString("ChangePassword", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to UPDATE User SET PasswordQuestion = $Question, PasswordAnswer = $Answer WHERE Username = $Username AND AppID = $AppID;.
        /// </summary>
        internal static string ChangePasswordQA {
            get {
                return ResourceManager.GetString("ChangePasswordQA", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to INSERT INTO User
        ///(
        ///	Username,
        ///	Password,
        ///	Email,
        ///	PasswordQuestion,
        ///	PasswordAnswer,
        ///	IsApproved,
        ///	Comment,
        ///	CreationDate,
        ///	LastPasswordChangedDate,
        ///	LastActivityDate,
        ///	AppID,
        ///	IsLockedOut,
        ///	LastLockedOutDate,
        ///	FailedPasswordAttemptCount,
        ///	FailedPasswordAttemptWindowStart,
        ///	FailedPasswordAnswerAttemptCount,
        ///	FailedPasswordAnswerAttemptWindowStart
        ///)
        ///Values(
        ///	$Username,
        ///	$Password,
        ///	$Email,
        ///	$PasswordQuestion,
        ///	$PasswordAnswer,
        ///	$IsApproved,
        ///	&apos;&apos;,
        ///	datetime(&apos;now&apos;,&apos;utc&apos;),
        ///	datetime( [rest of string was truncated]&quot;;.
        /// </summary>
        internal static string CreateUser {
            get {
                return ResourceManager.GetString("CreateUser", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to DELETE FROM User WHERE Username = $Username AND AppID = $AppID;.
        /// </summary>
        internal static string DeleteUser {
            get {
                return ResourceManager.GetString("DeleteUser", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to SELECT UserID, Username, Email, PasswordQuestion,
        ///Comment, IsApproved, IsLockedOut, CreationDate, LastLoginDate,
        ///LastActivityDate, LastPasswordChangedDate, LastLockedOutDate 
        ///FROM User 
        ///WHERE Email LIKE $EmailSearch AND AppID = $AppID 
        ///ORDER BY Username Asc
        ///LIMIT $Count, $Skip .
        /// </summary>
        internal static string FindUsersByEmail {
            get {
                return ResourceManager.GetString("FindUsersByEmail", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to SELECT UserID, Username, Email, PasswordQuestion,
        ///Comment, IsApproved, IsLockedOut, CreationDate, LastLoginDate,
        ///LastActivityDate, LastPasswordChangedDate, LastLockedOutDate 
        ///FROM User 
        ///WHERE Username LIKE $UsernameSearch AND AppID = $AppID
        ///ORDER BY Username Asc
        ///LIMIT $Count, $Skip .
        /// </summary>
        internal static string FindUsersByName {
            get {
                return ResourceManager.GetString("FindUsersByName", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to SELECT 
        ///	UserID, Username, Email, PasswordQuestion, Comment, IsApproved, IsLockedOut, CreationDate, LastLoginDate, LastActivityDate, LastPasswordChangedDate, LastLockedOutDate 
        ///FROM 
        ///	User 
        ///WHERE 
        ///	AppID = $AppID 
        ///ORDER BY 
        ///	Username Asc
        ///LIMIT
        ///	$Skip, $Count.
        /// </summary>
        internal static string GetAppUsers {
            get {
                return ResourceManager.GetString("GetAppUsers", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to SELECT Password, PasswordAnswer, IsLockedOut FROM User WHERE Username = $Username AND AppID = $AppID;.
        /// </summary>
        internal static string GetPassword {
            get {
                return ResourceManager.GetString("GetPassword", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to SELECT UserID, Username, Email, PasswordQuestion,
        ///Comment, IsApproved, IsLockedOut, CreationDate, LastLoginDate,
        ///LastActivityDate, LastPasswordChangedDate, LastLockedOutDate
        ///FROM User WHERE UserID = $UserID;.
        /// </summary>
        internal static string GetUserByID {
            get {
                return ResourceManager.GetString("GetUserByID", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to SELECT 
        ///	UserID, Username, Email, PasswordQuestion, Comment, 
        ///	IsApproved, IsLockedOut, CreationDate, LastLoginDate, 
        ///	LastActivityDate, LastPasswordChangedDate, LastLockedOutDate 
        ///FROM 
        ///	User 
        ///WHERE 
        ///	Username = $Username AND AppID = $AppID;.
        /// </summary>
        internal static string GetUserByName {
            get {
                return ResourceManager.GetString("GetUserByName", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to SELECT Username  FROM User WHERE Email = $Email AND AppID = $AppID;.
        /// </summary>
        internal static string GetUserNameByEmail {
            get {
                return ResourceManager.GetString("GetUserNameByEmail", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to SELECT Count(*) FROM User WHERE LastActivityDate &gt; $CompareDate AND AppID = $AppID;.
        /// </summary>
        internal static string GetUsersOnline {
            get {
                return ResourceManager.GetString("GetUsersOnline", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to UPDATE User
        ///SET IsLockedOut = $IsLockedOut, LastLockedOutDate = datetime(&apos;now&apos;,&apos;utc&apos;)
        ///WHERE Username = $Username AND AppID = $AppID.
        /// </summary>
        internal static string LockOutUser {
            get {
                return ResourceManager.GetString("LockOutUser", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to SELECT FailedPasswordAttemptCount, 
        ///FailedPasswordAttemptWindowStart, 
        ///FailedPasswordAnswerAttemptCount, 
        ///FailedPasswordAnswerAttemptWindowStart 
        ///FROM User 
        ///WHERE Username = $Username AND AppID = $AppID.
        /// </summary>
        internal static string QueryFailureCount {
            get {
                return ResourceManager.GetString("QueryFailureCount", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to SELECT PasswordAnswer, IsLockedOut FROM User WHERE Username = $Username AND AppID = $AppID;.
        /// </summary>
        internal static string QueryPasswordReset {
            get {
                return ResourceManager.GetString("QueryPasswordReset", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to UPDATE User SET Password = $Password, LastPasswordChangedDate = datetime(&apos;now&apos;,&apos;utc&apos;) WHERE Username = $Username AND AppID = $AppID AND IsLockedOut = 0.
        /// </summary>
        internal static string ResetPassword {
            get {
                return ResourceManager.GetString("ResetPassword", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to UPDATE User 
        ///SET IsLockedOut = 0, LastLockedOutDate = datetime(&apos;now&apos;,&apos;utc&apos;) 
        ///WHERE Username = $Username AND AppID = $AppID;.
        /// </summary>
        internal static string UnlockUser {
            get {
                return ResourceManager.GetString("UnlockUser", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to UPDATE User 
        ///SET LastActivityDate = datetime(&apos;now&apos;,&apos;utc&apos;) 
        ///WHERE UserID = $UserID;.
        /// </summary>
        internal static string UpdateAccessTimeByID {
            get {
                return ResourceManager.GetString("UpdateAccessTimeByID", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to UPDATE User 
        ///SET FailedPasswordAnswerAttemptCount = $Count
        ///WHERE Username = $Username AND AppID = $AppID.
        /// </summary>
        internal static string UpdateAnswerFailureCount {
            get {
                return ResourceManager.GetString("UpdateAnswerFailureCount", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to UPDATE User 
        ///SET FailedPasswordAnswerAttemptCount = $Count, 
        ///FailedPasswordAnswerAttemptWindowStart = datetime(&apos;now&apos;,&apos;utc&apos;) 
        ///WHERE Username = $Username AND AppID = $AppID.
        /// </summary>
        internal static string UpdateAnswerFailureCountStart {
            get {
                return ResourceManager.GetString("UpdateAnswerFailureCountStart", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to UPDATE User SET LastLoginDate = datetime(&apos;now&apos;,&apos;utc&apos;) WHERE Username = $Username AND AppID = $AppID.
        /// </summary>
        internal static string UpdateLastLoginDate {
            get {
                return ResourceManager.GetString("UpdateLastLoginDate", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to UPDATE User 
        ///SET FailedPasswordAttemptCount = $Count
        ///WHERE Username = $Username AND AppID = $AppID.
        /// </summary>
        internal static string UpdatePasswordFailureCount {
            get {
                return ResourceManager.GetString("UpdatePasswordFailureCount", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to UPDATE User 
        ///SET FailedPasswordAttemptCount = $Count, 
        ///FailedPasswordAttemptWindowStart = datetime(&apos;now&apos;,&apos;utc&apos;) 
        ///WHERE Username = $Username AND AppID = $AppID.
        /// </summary>
        internal static string UpdatePasswordFailureCountStart {
            get {
                return ResourceManager.GetString("UpdatePasswordFailureCountStart", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to UPDATE User
        ///SET Email = $Email, Comment = $Comment,
        ///IsApproved = $IsApproved
        ///WHERE Username = $Username AND AppID = $AppID.
        /// </summary>
        internal static string UpdateUser {
            get {
                return ResourceManager.GetString("UpdateUser", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to UPDATE User SET LastActivityDate = datetime(&apos;now&apos;,&apos;utc&apos;) WHERE Username = $Username AND AppID = $AppID;.
        /// </summary>
        internal static string UpdateUserAccessTimeByName {
            get {
                return ResourceManager.GetString("UpdateUserAccessTimeByName", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to SELECT Password, IsApproved FROM User WHERE Username = $Username AND AppID = $AppID AND IsLockedOut = 0.
        /// </summary>
        internal static string ValidateUser {
            get {
                return ResourceManager.GetString("ValidateUser", resourceCulture);
            }
        }
    }
}

Added Membership/Sql/MembershipSql.resx.

















































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<?xml version="1.0" encoding="utf-8"?>
<root>
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <data name="ChangePassword" xml:space="preserve">
    <value>UPDATE User SET Password = $Password, LastPasswordChangedDate = datetime('now','utc') WHERE Username = $Username AND AppID = $AppID;</value>
  </data>
  <data name="ChangePasswordQA" xml:space="preserve">
    <value>UPDATE User SET PasswordQuestion = $Question, PasswordAnswer = $Answer WHERE Username = $Username AND AppID = $AppID;</value>
  </data>
  <data name="CreateUser" xml:space="preserve">
    <value>INSERT INTO User
(
	Username,
	Password,
	Email,
	PasswordQuestion,
	PasswordAnswer,
	IsApproved,
	Comment,
	CreationDate,
	LastPasswordChangedDate,
	LastActivityDate,
	AppID,
	IsLockedOut,
	LastLockedOutDate,
	FailedPasswordAttemptCount,
	FailedPasswordAttemptWindowStart,
	FailedPasswordAnswerAttemptCount,
	FailedPasswordAnswerAttemptWindowStart
)
Values(
	$Username,
	$Password,
	$Email,
	$PasswordQuestion,
	$PasswordAnswer,
	$IsApproved,
	'',
	datetime('now','utc'),
	datetime('now','utc'),
	datetime('now','utc'),
	$AppID,
	$IsLockedOut,
	datetime('now','utc'),
	0,
	datetime('now','utc'),
	0,
	datetime('now','utc')
);</value>
  </data>
  <data name="DeleteUser" xml:space="preserve">
    <value>DELETE FROM User WHERE Username = $Username AND AppID = $AppID;</value>
  </data>
  <data name="FindUsersByEmail" xml:space="preserve">
    <value>SELECT UserID, Username, Email, PasswordQuestion,
Comment, IsApproved, IsLockedOut, CreationDate, LastLoginDate,
LastActivityDate, LastPasswordChangedDate, LastLockedOutDate 
FROM User 
WHERE Email LIKE $EmailSearch AND AppID = $AppID 
ORDER BY Username Asc
LIMIT $Count, $Skip </value>
  </data>
  <data name="FindUsersByName" xml:space="preserve">
    <value>SELECT UserID, Username, Email, PasswordQuestion,
Comment, IsApproved, IsLockedOut, CreationDate, LastLoginDate,
LastActivityDate, LastPasswordChangedDate, LastLockedOutDate 
FROM User 
WHERE Username LIKE $UsernameSearch AND AppID = $AppID
ORDER BY Username Asc
LIMIT $Count, $Skip </value>
  </data>
  <data name="GetAppUsers" xml:space="preserve">
    <value>SELECT 
	UserID, Username, Email, PasswordQuestion, Comment, IsApproved, IsLockedOut, CreationDate, LastLoginDate, LastActivityDate, LastPasswordChangedDate, LastLockedOutDate 
FROM 
	User 
WHERE 
	AppID = $AppID 
ORDER BY 
	Username Asc
LIMIT
	$Skip, $Count</value>
  </data>
  <data name="GetPassword" xml:space="preserve">
    <value>SELECT Password, PasswordAnswer, IsLockedOut FROM User WHERE Username = $Username AND AppID = $AppID;</value>
  </data>
  <data name="GetUserByID" xml:space="preserve">
    <value>SELECT UserID, Username, Email, PasswordQuestion,
Comment, IsApproved, IsLockedOut, CreationDate, LastLoginDate,
LastActivityDate, LastPasswordChangedDate, LastLockedOutDate
FROM User WHERE UserID = $UserID;</value>
  </data>
  <data name="GetUserByName" xml:space="preserve">
    <value>SELECT 
	UserID, Username, Email, PasswordQuestion, Comment, 
	IsApproved, IsLockedOut, CreationDate, LastLoginDate, 
	LastActivityDate, LastPasswordChangedDate, LastLockedOutDate 
FROM 
	User 
WHERE 
	Username = $Username AND AppID = $AppID;</value>
  </data>
  <data name="GetUserNameByEmail" xml:space="preserve">
    <value>SELECT Username  FROM User WHERE Email = $Email AND AppID = $AppID;</value>
  </data>
  <data name="GetUsersOnline" xml:space="preserve">
    <value>SELECT Count(*) FROM User WHERE LastActivityDate &gt; $CompareDate AND AppID = $AppID;</value>
  </data>
  <data name="LockOutUser" xml:space="preserve">
    <value>UPDATE User
SET IsLockedOut = $IsLockedOut, LastLockedOutDate = datetime('now','utc')
WHERE Username = $Username AND AppID = $AppID</value>
  </data>
  <data name="QueryFailureCount" xml:space="preserve">
    <value>SELECT FailedPasswordAttemptCount, 
FailedPasswordAttemptWindowStart, 
FailedPasswordAnswerAttemptCount, 
FailedPasswordAnswerAttemptWindowStart 
FROM User 
WHERE Username = $Username AND AppID = $AppID</value>
  </data>
  <data name="QueryPasswordReset" xml:space="preserve">
    <value>SELECT PasswordAnswer, IsLockedOut FROM User WHERE Username = $Username AND AppID = $AppID;</value>
  </data>
  <data name="ResetPassword" xml:space="preserve">
    <value>UPDATE User SET Password = $Password, LastPasswordChangedDate = datetime('now','utc') WHERE Username = $Username AND AppID = $AppID AND IsLockedOut = 0</value>
  </data>
  <data name="UnlockUser" xml:space="preserve">
    <value>UPDATE User 
SET IsLockedOut = 0, LastLockedOutDate = datetime('now','utc') 
WHERE Username = $Username AND AppID = $AppID;</value>
  </data>
  <data name="UpdateAccessTimeByID" xml:space="preserve">
    <value>UPDATE User 
SET LastActivityDate = datetime('now','utc') 
WHERE UserID = $UserID;</value>
  </data>
  <data name="UpdateAnswerFailureCount" xml:space="preserve">
    <value>UPDATE User 
SET FailedPasswordAnswerAttemptCount = $Count
WHERE Username = $Username AND AppID = $AppID</value>
  </data>
  <data name="UpdateAnswerFailureCountStart" xml:space="preserve">
    <value>UPDATE User 
SET FailedPasswordAnswerAttemptCount = $Count, 
FailedPasswordAnswerAttemptWindowStart = datetime('now','utc') 
WHERE Username = $Username AND AppID = $AppID</value>
  </data>
  <data name="UpdateLastLoginDate" xml:space="preserve">
    <value>UPDATE User SET LastLoginDate = datetime('now','utc') WHERE Username = $Username AND AppID = $AppID</value>
  </data>
  <data name="UpdatePasswordFailureCount" xml:space="preserve">
    <value>UPDATE User 
SET FailedPasswordAttemptCount = $Count
WHERE Username = $Username AND AppID = $AppID</value>
  </data>
  <data name="UpdatePasswordFailureCountStart" xml:space="preserve">
    <value>UPDATE User 
SET FailedPasswordAttemptCount = $Count, 
FailedPasswordAttemptWindowStart = datetime('now','utc') 
WHERE Username = $Username AND AppID = $AppID</value>
  </data>
  <data name="UpdateUser" xml:space="preserve">
    <value>UPDATE User
SET Email = $Email, Comment = $Comment,
IsApproved = $IsApproved
WHERE Username = $Username AND AppID = $AppID</value>
  </data>
  <data name="UpdateUserAccessTimeByName" xml:space="preserve">
    <value>UPDATE User SET LastActivityDate = datetime('now','utc') WHERE Username = $Username AND AppID = $AppID;</value>
  </data>
  <data name="ValidateUser" xml:space="preserve">
    <value>SELECT Password, IsApproved FROM User WHERE Username = $Username AND AppID = $AppID AND IsLockedOut = 0</value>
  </data>
</root>

Added Membership/Sql/RoleSql.Designer.cs.





















































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.42
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace SQLiteProvider {
    using System;
    
    
    /// <summary>
    ///   A strongly-typed resource class, for looking up localized strings, etc.
    /// </summary>
    // This class was auto-generated by the StronglyTypedResourceBuilder
    // class via a tool like ResGen or Visual Studio.
    // To add or remove a member, edit your .ResX file then rerun ResGen
    // with the /str option, or rebuild your VS project.
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    internal class RoleSql {
        
        private static global::System.Resources.ResourceManager resourceMan;
        
        private static global::System.Globalization.CultureInfo resourceCulture;
        
        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        internal RoleSql() {
        }
        
        /// <summary>
        ///   Returns the cached ResourceManager instance used by this class.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Resources.ResourceManager ResourceManager {
            get {
                if (object.ReferenceEquals(resourceMan, null)) {
                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SQLiteProvider.Sql.RoleSql", typeof(RoleSql).Assembly);
                    resourceMan = temp;
                }
                return resourceMan;
            }
        }
        
        /// <summary>
        ///   Overrides the current thread's CurrentUICulture property for all
        ///   resource lookups using this strongly typed resource class.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Globalization.CultureInfo Culture {
            get {
                return resourceCulture;
            }
            set {
                resourceCulture = value;
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Insert into UserRoleMap
        ///	(UserID, RoleID, AppID) values
        ///	(
        ///		(Select UserID from User where Username = $Username and AppID = $AppID),
        ///		(Select RoleID from Role where Rolename = $Rolename and AppID = $AppID),
        ///		$AppID
        ///	);.
        /// </summary>
        internal static string AddUserToRole {
            get {
                return ResourceManager.GetString("AddUserToRole", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Insert into Role (Rolename, AppID) values ($Rolename, $AppID);.
        /// </summary>
        internal static string CreateRole {
            get {
                return ResourceManager.GetString("CreateRole", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to DELETE FROM Role WHERE Rolename = $Rolename AND AppID = $AppID.
        /// </summary>
        internal static string DeleteRole {
            get {
                return ResourceManager.GetString("DeleteRole", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to DELETE FROM UserRoleMap WHERE RoleID = (Select RoleID from Role where Rolename = $Rolename  AND AppID = $AppID) AND AppID = $AppID.
        /// </summary>
        internal static string DeleteRoleFromMap {
            get {
                return ResourceManager.GetString("DeleteRoleFromMap", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Delete From UserRoleMap
        ///Where
        ///UserID = (Select UserID from User where Username = $Username and AppID = $AppID)
        ///AND
        ///RoleID = (Select RoleID from Role Rolename = $Rolename AND AppID = $AppID);
        ///.
        /// </summary>
        internal static string DeleteUserFromRole {
            get {
                return ResourceManager.GetString("DeleteUserFromRole", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Select User.Username from User
        ///Inner Join UserRoleMap on User.UserID = UserRoleMap.UserID
        ///Inner Join Role on UserRoleMap.RoleID = Role.RoleID
        ///Where Role.Rolename = $RoleName and Role.AppID = $AppID and User.Username Like $Username;.
        /// </summary>
        internal static string FindUsersInRole {
            get {
                return ResourceManager.GetString("FindUsersInRole", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to SELECT Rolename FROM Role WHERE AppID = $AppID.
        /// </summary>
        internal static string GetAllRoles {
            get {
                return ResourceManager.GetString("GetAllRoles", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Select Rolename from Role
        ///Inner Join UserRoleMap On Role.RoleID = UserRoleMap.RoleID and Role.AppID = UserRoleMap.AppID
        ///Inner Join User On User.UserID = UserRoleMap.UserID and User.AppID = UserRoleMap.AppID
        ///Where User.Username = $Username and User.AppID = $AppID;.
        /// </summary>
        internal static string GetRolesForUser {
            get {
                return ResourceManager.GetString("GetRolesForUser", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Select User.Username from User
        ///Inner Join UserRoleMap on User.UserID = UserRoleMap.UserID
        ///Inner Join Role on UserRoleMap.RoleID = Role.RoleID
        ///Where Role.Rolename = $RoleName and Role.AppID = $AppID;
        ///.
        /// </summary>
        internal static string GetUsersInRole {
            get {
                return ResourceManager.GetString("GetUsersInRole", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Select Count(*) from User
        ///Inner Join UserRoleMap on User.UserID = UserRoleMap.UserID
        ///Inner Join Role on UserRoleMap.RoleID = Role.RoleID
        ///Where Role.Rolename = $Rolename  and User.Username=$Username and Role.AppID = $AppID;.
        /// </summary>
        internal static string IsUserInRole {
            get {
                return ResourceManager.GetString("IsUserInRole", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to SELECT COUNT(*) FROM Role WHERE Rolename = $Rolename AND AppID = $AppID;.
        /// </summary>
        internal static string RoleExists {
            get {
                return ResourceManager.GetString("RoleExists", resourceCulture);
            }
        }
    }
}

Added Membership/Sql/RoleSql.resx.













































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?xml version="1.0" encoding="utf-8"?>
<root>
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <data name="AddUserToRole" xml:space="preserve">
    <value>Insert into UserRoleMap
	(UserID, RoleID, AppID) values
	(
		(Select UserID from User where Username = $Username and AppID = $AppID),
		(Select RoleID from Role where Rolename = $Rolename and AppID = $AppID),
		$AppID
	);</value>
  </data>
  <data name="CreateRole" xml:space="preserve">
    <value>Insert into Role (Rolename, AppID) values ($Rolename, $AppID);</value>
  </data>
  <data name="DeleteRole" xml:space="preserve">
    <value>DELETE FROM Role WHERE Rolename = $Rolename AND AppID = $AppID</value>
  </data>
  <data name="DeleteRoleFromMap" xml:space="preserve">
    <value>DELETE FROM UserRoleMap WHERE RoleID = (Select RoleID from Role where Rolename = $Rolename  AND AppID = $AppID) AND AppID = $AppID</value>
  </data>
  <data name="DeleteUserFromRole" xml:space="preserve">
    <value>Delete From UserRoleMap
Where
UserID = (Select UserID from User where Username = $Username and AppID = $AppID)
AND
RoleID = (Select RoleID from Role Rolename = $Rolename AND AppID = $AppID);
</value>
  </data>
  <data name="FindUsersInRole" xml:space="preserve">
    <value>Select User.Username from User
Inner Join UserRoleMap on User.UserID = UserRoleMap.UserID
Inner Join Role on UserRoleMap.RoleID = Role.RoleID
Where Role.Rolename = $RoleName and Role.AppID = $AppID and User.Username Like $Username;</value>
  </data>
  <data name="GetAllRoles" xml:space="preserve">
    <value>SELECT Rolename FROM Role WHERE AppID = $AppID</value>
  </data>
  <data name="GetRolesForUser" xml:space="preserve">
    <value>Select Rolename from Role
Inner Join UserRoleMap On Role.RoleID = UserRoleMap.RoleID and Role.AppID = UserRoleMap.AppID
Inner Join User On User.UserID = UserRoleMap.UserID and User.AppID = UserRoleMap.AppID
Where User.Username = $Username and User.AppID = $AppID;</value>
  </data>
  <data name="GetUsersInRole" xml:space="preserve">
    <value>Select User.Username from User
Inner Join UserRoleMap on User.UserID = UserRoleMap.UserID
Inner Join Role on UserRoleMap.RoleID = Role.RoleID
Where Role.Rolename = $RoleName and Role.AppID = $AppID;
</value>
  </data>
  <data name="IsUserInRole" xml:space="preserve">
    <value>Select Count(*) from User
Inner Join UserRoleMap on User.UserID = UserRoleMap.UserID
Inner Join Role on UserRoleMap.RoleID = Role.RoleID
Where Role.Rolename = $Rolename  and User.Username=$Username and Role.AppID = $AppID;</value>
  </data>
  <data name="RoleExists" xml:space="preserve">
    <value>SELECT COUNT(*) FROM Role WHERE Rolename = $Rolename AND AppID = $AppID;</value>
  </data>
</root>

Added Membership/Sql/Schema.sql.





























































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Create Table Application(
  AppID  INTEGER PRIMARY KEY,
  ApplicationName text
);

Create Table Role(
	RoleID INTEGER PRIMARY KEY,
	Rolename text,
	AppID integer NOT NULL
);

Create Table UserRoleMap(
	UserID integer NOT NULL,
	RoleID integer NOT NULL,
	AppID integer NOT NULL
);
	
CREATE TABLE User
(
  UserID INTEGER PRIMARY KEY,
  Username text NOT NULL,
  AppID integer NOT NULL,
  Email text  NOT NULL,
  Comment text,
  Password text NOT NULL,
  PasswordQuestion text,
  PasswordAnswer text,
  IsApproved bool, 
  LastActivityDate DateTime,
  LastLoginDate DateTime,
  LastPasswordChangedDate DateTime,
  CreationDate DateTime, 
  IsOnLine bool,
  IsLockedOut bool,
  LastLockedOutDate DateTime,
  FailedPasswordAttemptCount integer,
  FailedPasswordAttemptWindowStart DateTime,
  FailedPasswordAnswerAttemptCount integer,
  FailedPasswordAnswerAttemptWindowStart DateTime
);

Create Table SiteMapNode(
	NodeID	INTEGER PRIMARY KEY,
	AppID integer NOT NULL,
	Title text,
	Description text,
	Url text,
	Parent integer
);

Create Table SiteMapNodeRoles(
	NodeID integer NOT NULL,
	RoleID integer NOT NULL,
	AppID integer NOT NULL
);


--Create Table Profile(
--	ProfileID INTEGER PRIMARY KEY,
--	UserID integer NOT NULL,
--	AppID integer NOT NULL,
--	LastUpdatedDate Datetime,
--	LastActivityDate Datetime
--);
--
--Create Table ProfileData(
--	ItemID INTEGER PRIMARY KEY,
--	ProfileID integer NOT NULL,
--	ItemData BLOB,
--	ItemName text NOT NULL,
--	ItemFormat text NOT NULL
--);
--
--
-- -- Views
--Create View UserProfile As 
--Select Profile.ProfileID as ProfileID, User.UserName as UserName, Profile.LastActivityDate as LastActivityDate, Profile.LastUpdatedDate as LastUpdatedDate, User.AppID as AppID from Profile
--Inner Join User On Profile.UserID = User.UserID and Profile.AppID = User.AppID;

Added Membership/Sql/SiteMapSql.Designer.cs.







































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.42
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace SQLiteProvider {
    using System;
    
    
    /// <summary>
    ///   A strongly-typed resource class, for looking up localized strings, etc.
    /// </summary>
    // This class was auto-generated by the StronglyTypedResourceBuilder
    // class via a tool like ResGen or Visual Studio.
    // To add or remove a member, edit your .ResX file then rerun ResGen
    // with the /str option, or rebuild your VS project.
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    internal class SiteMapSql {
        
        private static global::System.Resources.ResourceManager resourceMan;
        
        private static global::System.Globalization.CultureInfo resourceCulture;
        
        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        internal SiteMapSql() {
        }
        
        /// <summary>
        ///   Returns the cached ResourceManager instance used by this class.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Resources.ResourceManager ResourceManager {
            get {
                if (object.ReferenceEquals(resourceMan, null)) {
                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SQLiteProvider.Sql.SiteMapSql", typeof(SiteMapSql).Assembly);
                    resourceMan = temp;
                }
                return resourceMan;
            }
        }
        
        /// <summary>
        ///   Overrides the current thread's CurrentUICulture property for all
        ///   resource lookups using this strongly typed resource class.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Globalization.CultureInfo Culture {
            get {
                return resourceCulture;
            }
            set {
                resourceCulture = value;
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Select RoleName from Role
        ///Inner Join SiteMapNodeRoles on Role.RoleID = SiteMapNodeRoles.RoleID and Role.AppID = SiteMapNodeRoles.AppID
        ///Where SiteMapNodeRoles.NodeID = $NodeID and Role.AppID = $AppID;.
        /// </summary>
        internal static string GetNodeRoles {
            get {
                return ResourceManager.GetString("GetNodeRoles", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Select NodeID, Title, Description, Url, Parent from SiteMapNode where AppID = $AppID order by Parent;.
        /// </summary>
        internal static string GetNodes {
            get {
                return ResourceManager.GetString("GetNodes", resourceCulture);
            }
        }
    }
}

Added Membership/Sql/SiteMapSql.resx.

































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!-- 
    Microsoft ResX Schema 
    
    Version 2.0
    
    The primary goals of this format is to allow a simple XML format 
    that is mostly human readable. The generation and parsing of the 
    various data types are done through the TypeConverter classes 
    associated with the data types.
    
    Example:
    
    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">2.0</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
        <value>[base64 mime encoded serialized .NET Framework object]</value>
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
        <comment>This is a comment</comment>
    </data>
                
    There are any number of "resheader" rows that contain simple 
    name/value pairs.
    
    Each data row contains a name, and value. The row also contains a 
    type or mimetype. Type corresponds to a .NET class that support 
    text/value conversion through the TypeConverter architecture. 
    Classes that don't support this are serialized and stored with the 
    mimetype set.
    
    The mimetype is used for serialized objects, and tells the 
    ResXResourceReader how to depersist the object. This is currently not 
    extensible. For a given mimetype the value must be set accordingly:
    
    Note - application/x-microsoft.net.object.binary.base64 is the format 
    that the ResXResourceWriter will generate, however the reader can 
    read any of the formats listed below.
    
    mimetype: application/x-microsoft.net.object.binary.base64
    value   : The object must be serialized with 
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with 
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
            : and then encoded with base64 encoding.

    mimetype: application/x-microsoft.net.object.bytearray.base64
    value   : The object must be serialized into a byte array 
            : using a System.ComponentModel.TypeConverter
            : and then encoded with base64 encoding.
    -->
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <data name="GetNodeRoles" xml:space="preserve">
    <value>Select RoleName from Role
Inner Join SiteMapNodeRoles on Role.RoleID = SiteMapNodeRoles.RoleID and Role.AppID = SiteMapNodeRoles.AppID
Where SiteMapNodeRoles.NodeID = $NodeID and Role.AppID = $AppID;</value>
  </data>
  <data name="GetNodes" xml:space="preserve">
    <value>Select NodeID, Title, Description, Url, Parent from SiteMapNode where AppID = $AppID order by Parent;</value>
  </data>
</root>

Added Membership/TODO.txt.

















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8

Optimize SQL.
Write some documentation eg: how to configure the provider via web.config
Dump SQL statements to some sort of human readable format & possibly document them.

? Create a default DB location & make the schema a resource so one can just plunk the provider in and have it just work with little or no config.
? Implement Profile Provider
? Implement a fully dynamic SiteMap Provider so changes to the DB get reflected immediatly

Added Membership/Utiliy/ProviderUtility.cs.







































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using System.Web.Security;
using System.Configuration.Provider;
using System.Collections.Specialized;
using System;
using System.Data;
using System.Data.SQLite;
using System.Configuration;
using System.Diagnostics;
using System.Web;
using System.Globalization;

namespace SQLiteProvider
{
    internal class ProviderUtility
    {

        public static void HandleException(Exception e, string source, string action, bool logging)
        {
            if (logging)
            {
                EventLog log = new EventLog();
                log.Source = source;
                log.Log = "Application";

                string message = "An exception occurred communicating with the data source.\n\n";
                message += "Action: " + action + "\n\n";
                message += "Exception: " + e.ToString();

                log.WriteEntry(message);
                throw new ProviderException("An exception occurred. Please check the Event Log.");
            }
            else
            {
                throw e;
            }
        }
        public static long GetApplicationID(String ConnString, string AppName)
        {
            long AppID = 0;
            SQLiteConnection conn = new SQLiteConnection(ConnString);
            SQLiteCommand existsCmd = new SQLiteCommand(ApplicationSql.AppExists, conn);
            SQLiteCommand idCmd = new SQLiteCommand(ApplicationSql.GetAppID, conn);
            SQLiteCommand insertCmd = new SQLiteCommand(ApplicationSql.InsertApp, conn);

            existsCmd.Parameters.Add("$ApplicationName", DbType.String).Value = AppName;
            idCmd.Parameters.Add("$ApplicationName", DbType.String).Value = AppName;
            insertCmd.Parameters.Add("$ApplicationName", DbType.String).Value = AppName;
            try
            {
                conn.Open();
                if (((long)existsCmd.ExecuteScalar()) == 0)
                {
                    insertCmd.ExecuteNonQuery();
                }
                AppID = (long)idCmd.ExecuteScalar();

            }
            catch (SQLiteException e)
            {
                ProviderUtility.HandleException(e, "Utility", "ApplicationName Property", false);
            }
            finally
            {
                conn.Close();
            }
            return AppID;
        }

        public static string GetConnectionString(string csName)
        {
            string cs = "";
            ConnectionStringSettings css = ConfigurationManager.ConnectionStrings[csName];

            if (css == null || css.ConnectionString.Trim() == "")
            {
                // use default location, creating the DB if need be
                throw new ProviderException("Connection string cannot be blank.");
            }
            else
            {
                cs = css.ConnectionString;
            }
            return cs;
        }
        public static string GetApplicationName(string appName)
        {
            return (String.IsNullOrEmpty(appName)? System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath:appName);
        }
        public static bool GetExceptionDesitination(string exToLog)
        {
            bool res = false;
            if (!String.IsNullOrEmpty(exToLog) && exToLog.ToUpper() == "TRUE")
            {
                res = true;
            }
            return res;
        }
    }
}

Added Membership/app.config.











>
>
>
>
>
1
2
3
4
5
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
    </configSections>
</configuration>