本文整理汇总了C#中Authenticator.CreateUsername方法的典型用法代码示例。如果您正苦于以下问题:C# Authenticator.CreateUsername方法的具体用法?C# Authenticator.CreateUsername怎么用?C# Authenticator.CreateUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Authenticator
的用法示例。
在下文中一共展示了Authenticator.CreateUsername方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateLogin
public BaseResponse CreateLogin(string memberId, string userName, string initialPassword, string postalCode)
{
methodName = "CreateLogin";
List<Message> errors = new List<Message>();
string errortext = string.Empty;
try
{
#region validate input
// All params are required
if ((memberId.Trim() == "")
|| (userName.Trim() == "")
|| (initialPassword.Trim() == "")
|| (postalCode.Trim() == ""))
{
errors.Add(new Message("ImproperValidationCriteriaException"));
}
using (HarperLINQ.AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
{
string exception = string.Empty;
bool exists = false;
int existing = (from a in context.tbl_Customers
join b in context.SFG_CustomerNumbers
on a.cusID equals b.cusID
where a.cusUserName == userName.Trim()
&& b.SFGCustNum != memberId.Trim()
select a).Count();
if (existing > 0)
{
exists = true;
exception = "User name is in use.";
}
existing = 0;
existing = (from a in context.tbl_Customers
join b in context.SFG_CustomerNumbers
on a.cusID equals b.cusID
where a.cusDisplayName == userName.Trim()
&& b.SFGCustNum != memberId.Trim()
select a).Count();
if (existing > 0)
{
exists = true;
exception += " Screen name is in use.";
}
existing = 0;
existing = (from a in context.tbl_Customers
join b in context.SFG_CustomerNumbers
on a.cusID equals b.cusID
where a.cusEmail == userName.Trim()
&& b.SFGCustNum != memberId.Trim()
select a).Count();
if (existing > 0)
{
exists = true;
exception += "Email address is in use.";
}
if (exists)
{
throw new Exception(exception);
}
}
#endregion
CreateLoginRequest request = new CreateLoginRequest(memberId.Trim(), userName.Trim(), initialPassword.Trim(), postalCode.Trim(), false);
baseResponse = UserMaintenance.CreateLogin(request);
if (baseResponse != null
&& baseResponse.TypedResponse != null
&& baseResponse.TypedResponse.GetType().Name == "CreateLoginResponse"
&& (baseResponse.TypedResponse as CreateLoginResponse).Success)
{
HarperACL.Authenticator auth = new Authenticator(userName.Trim(), Cryptography.Hash(initialPassword.Trim(),true), true, true, false, memberId.Trim());
if (!auth.CreateUsername(userName.Trim(), initialPassword.Trim(), memberId.Trim()))
{
throw new Exception("User created at SFG, could not create user at AH");
}
}
}
catch (Exception ex)
{
errortext = string.Format("Error creating login. Memberid: {0} Username: {1} Password: {2} PostalCode: {3} \r\nException message: {4}\r\nException stacktrace: {5}", new object[] { memberId, userName, initialPassword, postalCode, ex.Message, ex.StackTrace });
errors.Add(new Message(MessageSources.AndrewHarper, 0, "CreateLoginException", errortext, "", "", null));
}
foreach (Message error in errors)
{
if (baseResponse == null)
{
baseResponse = new BaseResponse();
}
baseResponse.Messages.Add(error);
StringBuilder error_text = new StringBuilder();
error_text.AppendLine("CREATELOGIN ERROR LOGGED");
error_text.AppendLine(string.Format("MEMBERID {0}", memberId));
baseResponse.Messages.Add(error);
error_text.AppendLine(string.Format("ERROR: {0}", new object[] { error.AhMessage}));
EventLogger.LogError("MembershipLogic.CreateLogin", error_text.ToString(), true);
}
return baseResponse;
}