public void CreateNormalUserCredential(string username, long credentialID)
        {
            var userObject = _context.DboCredential.SingleOrDefault(m => m.Vchr32Name == username);

            if (userObject != null)
            {
                userObject.BEnabled = true;
                _context.DboCredential.Update(userObject);
                _context.SaveChanges();

                DboCredentialHierarchy dbH = new DboCredentialHierarchy();
                dbH.BintParentCredentialId = credentialID;
                dbH.BintChildCredentialId  = userObject.BintId;
                dbH.DtCreated                       = DateTime.Now;
                dbH.Vchr256CreatedContext           = "Creating new Hierarchy for System10 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 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();
        }