public void CreateActiveDirectoryUserCredential(Models.LoginViewModel model) { string username = Utility.GetUserNameFromEmail(model.Email); DboCredential obj = new DboCredential(); obj.Vchr32Name = username; obj.Nvch128Caption = username; // obj.Bin64PasswordHash = string.Empty; obj.BEnabled = true; obj.DtCreated = DateTime.Now; obj.Vchr256CreatedContext = "Creating new Credential Record for Active Directory user"; obj.BintCreatorCredentialId = 1; obj.BintCreatorSpoofOfCredentialId = null; obj.DtModified = DateTime.Now; obj.Vchr256ModifiedContext = string.Empty; obj.BintModifierCredentialId = 1; obj.BintModifierSpoofOfCredentialId = null; obj.BSmokeTest = false; obj.BIsGroup = false; _context.DboCredential.Add(obj); _context.SaveChanges(); var credtype = _context.LkpLocalization.SingleOrDefault(m => m.Vchr128Identifier == "1" && m.NvchMaxText == "Active Directory User" && m.Vchr64LocalizationType == "Title"); DboCredentialAlternate objAl = new DboCredentialAlternate(); objAl.BintPrimaryCredentialId = obj.BintId; objAl.ICredentialTypeId = 1; objAl.Vchr64UserName = model.Email; objAl.DtCreated = DateTime.Now; objAl.Vchr256CreatedContext = "Creating new Credential Alternate Record for Active Directory user"; objAl.BintCreatorCredentialId = 1; objAl.BintCreatorSpoofOfCredentialId = null; objAl.DtModified = DateTime.Now; objAl.Vchr256ModifiedContext = string.Empty; objAl.BintModifierCredentialId = 1; objAl.BintModifierSpoofOfCredentialId = null; objAl.BSmokeTest = false; _context.DboCredentialAlternate.Add(objAl); _context.SaveChanges(); DboCredentialHierarchy dbH = new DboCredentialHierarchy(); dbH.BintParentCredentialId = obj.BintId; dbH.BintChildCredentialId = obj.BintId; dbH.DtCreated = DateTime.Now; dbH.Vchr256CreatedContext = "Creating new Hierarchy for Active Directory user"; dbH.BintCreatorCredentialId = 1; dbH.BintCreatorSpoofOfCredentialId = null; dbH.DtModified = DateTime.Now; dbH.Vchr256ModifiedContext = ""; dbH.BintModifierCredentialId = 1; dbH.BintModifierSpoofOfCredentialId = null; dbH.BSmokeTest = false; _context.DboCredentialHierarchy.Add(dbH); _context.SaveChanges(); }
public void CreateOAuthUserCredential(string email, long id, string provider) { // string username = Utility.GetUserNameFromEmail(model.Email); LkpLocalization objLoc = _context.LkpLocalization.SingleOrDefault(m => m.ILocalizationSetId == 1 && m.NvchMaxText == provider && m.Vchr64LocalizationType == "Title"); DboCredentialAlternate objAl = new DboCredentialAlternate(); objAl.BintPrimaryCredentialId = id; objAl.ICredentialTypeId = Convert.ToInt32(objLoc.Vchr128Identifier); objAl.Vchr64UserName = email; objAl.DtCreated = DateTime.Now; objAl.Vchr256CreatedContext = "Creating new OAuth for user"; objAl.BintCreatorCredentialId = 1; objAl.BintCreatorSpoofOfCredentialId = null; objAl.DtModified = DateTime.Now; objAl.Vchr256ModifiedContext = string.Empty; objAl.BintModifierCredentialId = 1; objAl.BintModifierSpoofOfCredentialId = null; objAl.BSmokeTest = false; _context.DboCredentialAlternate.Add(objAl); _context.SaveChanges(); }