/// <summary> /// Debug constructor /// </summary> /// <param name="signInSystem">The sign in system to use</param> /// <param name="dnaDataReaderCreator">A DnaDataReaderCreator object for creating the procedure this class needs. /// If NULL, it uses the connection stringsfrom the configuration manager</param> /// <param name="dnaDiagnostics">A DnaDiagnostics object for logging purposes</param> /// <param name="caching">The caching object that the class can use for caching</param> /// <param name="debugUserID">A userid for debugging/testing purposes</param> /// <param name="siteList">A SiteList object for getting siteoption values</param> public CallingUser(SignInSystem signInSystem, IDnaDataReaderCreator dnaDataReaderCreator, IDnaDiagnostics dnaDiagnostics, ICacheManager caching, string debugUserID, ISiteList siteList) : base(dnaDataReaderCreator, dnaDiagnostics, caching) { _signInSystem = signInSystem; _debugUserID = debugUserID; _siteList = siteList; }
/// <summary> /// This creates the specified sign in system component /// </summary> /// <param name="connectionString">The connection string for the component</param> /// <param name="signInSystem">Which signin system to create the component to talk to</param> /// <returns>The new signin component</returns> public static IDnaIdentityWebServiceProxy CreateSignInComponent(string connectionString, SignInSystem signInSystem) { try { if (signInSystem == SignInSystem.Identity) { return new DnaIdentityWebServiceProxy.IdentityRestSignIn(connectionString, ""); } #if DEBUG else if (signInSystem == SignInSystem.DebugIdentity) { return new DnaIdentityWebServiceProxy.IdentityDebugSigninComponent(connectionString); } #endif else { throw new Exception("SSO Signin model nolonger supported!!"); } } catch (Exception Ex) { throw Ex; } }
/// <summary> /// This method gets the users DNA UserID for the given SignIn UserID /// </summary> /// <param name="signInUserID">The users signin user id</param> /// <param name="signInType">The signin system the id belongs to</param> /// <returns>The DNA User ID</returns> private int GetDnaUserIDFromSignInID(int signInUserID, SignInSystem signInType) { string procedureName = "GetDnaUserIDFromIdentityUserID"; string signInIDName = "IdentityUserID"; using (IDnaDataReader reader = CreateStoreProcedureReader(procedureName)) { reader.AddParameter(signInIDName, signInUserID); reader.Execute(); if (reader.HasRows && reader.Read()) { UserID = reader.GetInt32("DnaUserID"); } } return UserID; }
/// <summary> /// Default constructor for UserSecurity /// </summary> /// <param name="signInSystem">The signin component to use</param> public AuthenticateUser(SignInSystem signInSystem) { _signInSystem = signInSystem; string signinConnectionDetails = ConfigurationManager.ConnectionStrings["IdentityURL"].ConnectionString; _signInComponent = SignInComponentFactory.CreateSignInComponent(signinConnectionDetails, _signInSystem); }
/// <summary> /// Creates a user using their DNA User ID /// </summary> /// <param name="userSignInID">The users SignIn ID</param> /// <param name="legacyUserID">The sso legacy userid if they have one</param> /// <param name="signInType">The type of the sign in ID. Identity or SSO</param> /// <param name="siteID">The site that you want to create the user in</param> /// <param name="loginName">The login name for the user</param> /// <param name="email">The users email</param> /// <param name="displayName">The users display name if gievn</param> /// <returns>True if they we're created ok, false if not</returns> public bool CreateUserFromSignInUserID(string userSignInID, int legacyUserID, SignInSystem signInType, int siteID, string loginName, string email, string displayName,string ipAddress, Guid BBCUid ) { bool userCreated = false; IdentityUserID = userSignInID; Trace.WriteLine("CreateUserFromSignInUserID() - Using Identity"); userCreated = CreateNewUserFromId(siteID, IdentityUserID, legacyUserID, loginName, email, displayName,ipAddress, BBCUid ); if (userCreated) { GetUsersGroupsForSite(); } return userCreated; }