PageRenderTime 60ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/mysql/YAF.Providers/Passthru/YAFMembershipPassThru.cs

https://github.com/vzrus/YetAnotherForumExtraDataLayers
C# | 494 lines | 177 code | 35 blank | 282 comment | 4 complexity | 8566b1439e8865d446d2803a8c133d57 MD5 | raw file
  1. /* Yet Another Forum.NET
  2. * Copyright (C) 2006-2012 Jaben Cargman
  3. * http://www.yetanotherforum.net/
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. using System.Collections.Specialized;
  20. using System.Configuration.Provider;
  21. using System.Web.Security;
  22. namespace YAFProviders.Passthru
  23. {
  24. /// <summary>
  25. /// The yaf membership pass thru.
  26. /// </summary>
  27. internal class YAFMembershipPassThru : MembershipProvider
  28. {
  29. /// <summary>
  30. /// The _real provider.
  31. /// </summary>
  32. private MembershipProvider _realProvider;
  33. /// <summary>
  34. /// Gets or sets ApplicationName.
  35. /// </summary>
  36. public override string ApplicationName
  37. {
  38. get
  39. {
  40. return this._realProvider.ApplicationName;
  41. }
  42. set
  43. {
  44. this._realProvider.ApplicationName = value;
  45. }
  46. }
  47. /// <summary>
  48. /// Gets a value indicating whether EnablePasswordReset.
  49. /// </summary>
  50. public override bool EnablePasswordReset
  51. {
  52. get
  53. {
  54. return this._realProvider.EnablePasswordReset;
  55. }
  56. }
  57. /// <summary>
  58. /// Gets a value indicating whether EnablePasswordRetrieval.
  59. /// </summary>
  60. public override bool EnablePasswordRetrieval
  61. {
  62. get
  63. {
  64. return this._realProvider.EnablePasswordRetrieval;
  65. }
  66. }
  67. /// <summary>
  68. /// Gets MaxInvalidPasswordAttempts.
  69. /// </summary>
  70. public override int MaxInvalidPasswordAttempts
  71. {
  72. get
  73. {
  74. return this._realProvider.MaxInvalidPasswordAttempts;
  75. }
  76. }
  77. /// <summary>
  78. /// Gets MinRequiredNonAlphanumericCharacters.
  79. /// </summary>
  80. public override int MinRequiredNonAlphanumericCharacters
  81. {
  82. get
  83. {
  84. return this._realProvider.MinRequiredNonAlphanumericCharacters;
  85. }
  86. }
  87. /// <summary>
  88. /// Gets MinRequiredPasswordLength.
  89. /// </summary>
  90. public override int MinRequiredPasswordLength
  91. {
  92. get
  93. {
  94. return this._realProvider.MinRequiredPasswordLength;
  95. }
  96. }
  97. /// <summary>
  98. /// Gets PasswordAttemptWindow.
  99. /// </summary>
  100. public override int PasswordAttemptWindow
  101. {
  102. get
  103. {
  104. return this._realProvider.PasswordAttemptWindow;
  105. }
  106. }
  107. /// <summary>
  108. /// Gets PasswordFormat.
  109. /// </summary>
  110. public override MembershipPasswordFormat PasswordFormat
  111. {
  112. get
  113. {
  114. return this._realProvider.PasswordFormat;
  115. }
  116. }
  117. /// <summary>
  118. /// Gets PasswordStrengthRegularExpression.
  119. /// </summary>
  120. public override string PasswordStrengthRegularExpression
  121. {
  122. get
  123. {
  124. return this._realProvider.PasswordStrengthRegularExpression;
  125. }
  126. }
  127. /// <summary>
  128. /// Gets a value indicating whether RequiresQuestionAndAnswer.
  129. /// </summary>
  130. public override bool RequiresQuestionAndAnswer
  131. {
  132. get
  133. {
  134. return this._realProvider.RequiresQuestionAndAnswer;
  135. }
  136. }
  137. /// <summary>
  138. /// Gets a value indicating whether RequiresUniqueEmail.
  139. /// </summary>
  140. public override bool RequiresUniqueEmail
  141. {
  142. get
  143. {
  144. return this._realProvider.RequiresUniqueEmail;
  145. }
  146. }
  147. /// <summary>
  148. /// The initialize.
  149. /// </summary>
  150. /// <param name="name">
  151. /// The name.
  152. /// </param>
  153. /// <param name="config">
  154. /// The config.
  155. /// </param>
  156. /// <exception cref="ProviderException">
  157. /// </exception>
  158. public override void Initialize(string name, NameValueCollection config)
  159. {
  160. string realProviderName = config["passThru"];
  161. if (realProviderName == null || realProviderName.Length < 1)
  162. {
  163. throw new ProviderException("Pass Thru provider name has not been specified in the web.config");
  164. }
  165. // Remove passThru configuration attribute
  166. config.Remove("passThru");
  167. // Check for further attributes
  168. if (config.Count > 0)
  169. {
  170. // Throw Provider error as no more attributes were expected
  171. throw new ProviderException("Unrecognised Attribute on the Membership PassThru Provider");
  172. }
  173. // Initialise the "Real" membership provider
  174. this._realProvider = Membership.Providers[realProviderName];
  175. }
  176. /// <summary>
  177. /// The change password.
  178. /// </summary>
  179. /// <param name="username">
  180. /// The username.
  181. /// </param>
  182. /// <param name="oldPassword">
  183. /// The old password.
  184. /// </param>
  185. /// <param name="newPassword">
  186. /// The new password.
  187. /// </param>
  188. /// <returns>
  189. /// The change password.
  190. /// </returns>
  191. public override bool ChangePassword(string username, string oldPassword, string newPassword)
  192. {
  193. return this._realProvider.ChangePassword(username, oldPassword, newPassword);
  194. }
  195. /// <summary>
  196. /// The change password question and answer.
  197. /// </summary>
  198. /// <param name="username">
  199. /// The username.
  200. /// </param>
  201. /// <param name="password">
  202. /// The password.
  203. /// </param>
  204. /// <param name="newPasswordQuestion">
  205. /// The new password question.
  206. /// </param>
  207. /// <param name="newPasswordAnswer">
  208. /// The new password answer.
  209. /// </param>
  210. /// <returns>
  211. /// The change password question and answer.
  212. /// </returns>
  213. public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer)
  214. {
  215. return this._realProvider.ChangePasswordQuestionAndAnswer(username, password, newPasswordQuestion, newPasswordAnswer);
  216. }
  217. /// <summary>
  218. /// The create user.
  219. /// </summary>
  220. /// <param name="username">
  221. /// The username.
  222. /// </param>
  223. /// <param name="password">
  224. /// The password.
  225. /// </param>
  226. /// <param name="email">
  227. /// The email.
  228. /// </param>
  229. /// <param name="passwordQuestion">
  230. /// The password question.
  231. /// </param>
  232. /// <param name="passwordAnswer">
  233. /// The password answer.
  234. /// </param>
  235. /// <param name="isApproved">
  236. /// The is approved.
  237. /// </param>
  238. /// <param name="providerUserKey">
  239. /// The provider user key.
  240. /// </param>
  241. /// <param name="status">
  242. /// The status.
  243. /// </param>
  244. /// <returns>
  245. /// </returns>
  246. public override MembershipUser CreateUser(
  247. string username,
  248. string password,
  249. string email,
  250. string passwordQuestion,
  251. string passwordAnswer,
  252. bool isApproved,
  253. object providerUserKey,
  254. out MembershipCreateStatus status)
  255. {
  256. return this._realProvider.CreateUser(username, password, email, passwordQuestion, passwordAnswer, isApproved, providerUserKey, out status);
  257. }
  258. /// <summary>
  259. /// The delete user.
  260. /// </summary>
  261. /// <param name="username">
  262. /// The username.
  263. /// </param>
  264. /// <param name="deleteAllRelatedData">
  265. /// The delete all related data.
  266. /// </param>
  267. /// <returns>
  268. /// The delete user.
  269. /// </returns>
  270. public override bool DeleteUser(string username, bool deleteAllRelatedData)
  271. {
  272. return this._realProvider.DeleteUser(username, deleteAllRelatedData);
  273. }
  274. /// <summary>
  275. /// The find users by email.
  276. /// </summary>
  277. /// <param name="emailToMatch">
  278. /// The email to match.
  279. /// </param>
  280. /// <param name="pageIndex">
  281. /// The page index.
  282. /// </param>
  283. /// <param name="pageSize">
  284. /// The page size.
  285. /// </param>
  286. /// <param name="totalRecords">
  287. /// The total records.
  288. /// </param>
  289. /// <returns>
  290. /// </returns>
  291. public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
  292. {
  293. return this._realProvider.FindUsersByEmail(emailToMatch, pageIndex, pageSize, out totalRecords);
  294. }
  295. /// <summary>
  296. /// The find users by name.
  297. /// </summary>
  298. /// <param name="usernameToMatch">
  299. /// The username to match.
  300. /// </param>
  301. /// <param name="pageIndex">
  302. /// The page index.
  303. /// </param>
  304. /// <param name="pageSize">
  305. /// The page size.
  306. /// </param>
  307. /// <param name="totalRecords">
  308. /// The total records.
  309. /// </param>
  310. /// <returns>
  311. /// </returns>
  312. public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
  313. {
  314. return this._realProvider.FindUsersByName(usernameToMatch, pageIndex, pageSize, out totalRecords);
  315. }
  316. /// <summary>
  317. /// The get all users.
  318. /// </summary>
  319. /// <param name="pageIndex">
  320. /// The page index.
  321. /// </param>
  322. /// <param name="pageSize">
  323. /// The page size.
  324. /// </param>
  325. /// <param name="totalRecords">
  326. /// The total records.
  327. /// </param>
  328. /// <returns>
  329. /// </returns>
  330. public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
  331. {
  332. return this._realProvider.GetAllUsers(pageIndex, pageSize, out totalRecords);
  333. }
  334. /// <summary>
  335. /// The get number of users online.
  336. /// </summary>
  337. /// <returns>
  338. /// The get number of users online.
  339. /// </returns>
  340. public override int GetNumberOfUsersOnline()
  341. {
  342. return this._realProvider.GetNumberOfUsersOnline();
  343. }
  344. /// <summary>
  345. /// The get password.
  346. /// </summary>
  347. /// <param name="username">
  348. /// The username.
  349. /// </param>
  350. /// <param name="answer">
  351. /// The answer.
  352. /// </param>
  353. /// <returns>
  354. /// The get password.
  355. /// </returns>
  356. public override string GetPassword(string username, string answer)
  357. {
  358. return this._realProvider.GetPassword(username, answer);
  359. }
  360. /// <summary>
  361. /// The get user.
  362. /// </summary>
  363. /// <param name="username">
  364. /// The username.
  365. /// </param>
  366. /// <param name="userIsOnline">
  367. /// The user is online.
  368. /// </param>
  369. /// <returns>
  370. /// </returns>
  371. public override MembershipUser GetUser(string username, bool userIsOnline)
  372. {
  373. return this._realProvider.GetUser(username, userIsOnline);
  374. }
  375. /// <summary>
  376. /// The get user.
  377. /// </summary>
  378. /// <param name="providerUserKey">
  379. /// The provider user key.
  380. /// </param>
  381. /// <param name="userIsOnline">
  382. /// The user is online.
  383. /// </param>
  384. /// <returns>
  385. /// </returns>
  386. public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
  387. {
  388. return this._realProvider.GetUser(providerUserKey, userIsOnline);
  389. }
  390. /// <summary>
  391. /// The get user name by email.
  392. /// </summary>
  393. /// <param name="email">
  394. /// The email.
  395. /// </param>
  396. /// <returns>
  397. /// The get user name by email.
  398. /// </returns>
  399. public override string GetUserNameByEmail(string email)
  400. {
  401. return this._realProvider.GetUserNameByEmail(email);
  402. }
  403. /// <summary>
  404. /// The reset password.
  405. /// </summary>
  406. /// <param name="username">
  407. /// The username.
  408. /// </param>
  409. /// <param name="answer">
  410. /// The answer.
  411. /// </param>
  412. /// <returns>
  413. /// The reset password.
  414. /// </returns>
  415. public override string ResetPassword(string username, string answer)
  416. {
  417. return this._realProvider.ResetPassword(username, answer);
  418. }
  419. /// <summary>
  420. /// The unlock user.
  421. /// </summary>
  422. /// <param name="userName">
  423. /// The user name.
  424. /// </param>
  425. /// <returns>
  426. /// The unlock user.
  427. /// </returns>
  428. public override bool UnlockUser(string userName)
  429. {
  430. return this._realProvider.UnlockUser(userName);
  431. }
  432. /// <summary>
  433. /// The update user.
  434. /// </summary>
  435. /// <param name="user">
  436. /// The user.
  437. /// </param>
  438. public override void UpdateUser(MembershipUser user)
  439. {
  440. this._realProvider.UpdateUser(user);
  441. }
  442. /// <summary>
  443. /// The validate user.
  444. /// </summary>
  445. /// <param name="username">
  446. /// The username.
  447. /// </param>
  448. /// <param name="password">
  449. /// The password.
  450. /// </param>
  451. /// <returns>
  452. /// The validate user.
  453. /// </returns>
  454. public override bool ValidateUser(string username, string password)
  455. {
  456. return this._realProvider.ValidateUser(username, password);
  457. }
  458. }
  459. }