コード例 #1
0
        /// <summary>
        /// Adds mapping
        /// </summary>
        /// <param name="application">Affiliate application</param>
        /// <param name="user">Windows user</param>
        /// <param name="XU">External user</param>
        /// <param name="XP">External password</param>
        /// <returns>True if successful, otherwise false</returns>
        public static bool AddMapping(string application, string user, string XU, string XP)
        {
            try
            {
                // Set mapping
                ISSOMapper  mapper  = new ISSOMapper();
                ISSOMapping mapping = new ISSOMapping();

                string username   = user.Substring(user.IndexOf('\\') + 1);
                string userdomain = user.Substring(0, user.IndexOf('\\'));

                mapping.WindowsDomainName = userdomain;
                mapping.WindowsUserName   = username;
                mapping.ApplicationName   = application;
                mapping.ExternalUserName  = XU;

                mapping.Create(0);

                // Set credentials
                string[] credentials = new string[] { XP };
                mapper.SetExternalCredentials(application, XU, ref credentials);

                mapping.Enable(0);
            }
            catch
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
        public static string[] GetCurrentUserApplications()
        {
            if (_applications == null)
            {
                ISSOMapper mapper = new ISSOMapper();

                AffiliateApplicationType appTypes = AffiliateApplicationType.ConfigStore;

                IPropertyBag propBag = (IPropertyBag)mapper;

                uint appFilterFlagMask = SSOFlag.SSO_FLAG_APP_FILTER_BY_TYPE;

                uint appFilterFlags = (uint)appTypes;

                object appFilterFlagsObj = appFilterFlags;

                object appFilterFlagMaskObj = appFilterFlagMask;

                propBag.Write("AppFilterFlags", ref appFilterFlagsObj);

                propBag.Write("AppFilterFlagMask", ref appFilterFlagMaskObj);

                string[] descs;
                string[] contacts;

                mapper.GetApplications(out _applications, out descs, out contacts);
            }
            return(_applications);
        }
コード例 #3
0
 /// <summary>
 /// Adds an account mapping to an affiliate application.
 /// </summary>
 /// <param name="application">The affiliate application to which the account mapping will be added.</param>
 /// <param name="accounts">The account(s) that will use the mapping.</param>
 /// <param name="externalUserid">The external user id to map the accounts to.</param>
 /// <param name="externalPassword">The external password to map the accounts to.</param>
 public void Map(string application, string accounts, string externalUserid, string externalPassword)
 {
     try
     {
         string[] accountList = accounts.Split(';');
         foreach (string account in accountList)
         {
             string accountDomain = account.Substring(0, account.IndexOf('\\'));
             string accountName   = account.Substring(account.IndexOf('\\') + 1);
             try
             {
                 // Create mapping.
                 ISSOMapping mapping = new ISSOMapping();
                 mapping.ApplicationName   = application;
                 mapping.WindowsDomainName = accountDomain;
                 mapping.WindowsUserName   = accountName;
                 mapping.ExternalUserName  = externalUserid;
                 mapping.Create(SSOFlag.SSO_FLAG_ENABLED);
                 // Set credentials.
                 ISSOMapper mapper      = new ISSOMapper();
                 string[]   credentials = new string[] { externalPassword };
                 mapper.SetExternalCredentials(application, externalUserid, ref credentials);
             }
             catch (Exception e)
             {
                 throw new Exception("Failed to map account " + accountDomain + "\\" + accountName + " to external user " + externalUserid + " for application " + application + ". " + e.Message);
             }
         }
     }
     catch (Exception e)
     {
         throw new Exception("Failed to map account(s) " + accounts + " to application " + application + ". " + e.Message);
     }
 }
コード例 #4
0
ファイル: SSOConfigManager.cs プロジェクト: manjzu/BTSSO
        public static IDictionary <string, string> GetApplications()
        {
            ISSOMapper ssoMapper = (ISSOMapper) new SSOMapper();
            AffiliateApplicationType affiliateApplicationType = AffiliateApplicationType.ConfigStore;
            IPropertyBag             propertyBag = (IPropertyBag)ssoMapper;
            uint   num     = 1;
            object ptrVar1 = (object)(uint)affiliateApplicationType;
            object ptrVar2 = (object)num;

            propertyBag.Write("AppFilterFlags", ref ptrVar1);
            propertyBag.Write("AppFilterFlagMask", ref ptrVar2);
            string[] applications = (string[])null;
            string[] descriptions = (string[])null;
            string[] contactInfo  = (string[])null;
            ssoMapper.GetApplications(out applications, out descriptions, out contactInfo);
            Dictionary <string, string> dictionary1 = new Dictionary <string, string>(applications.Length);
            Dictionary <string, string> dictionary2 = new Dictionary <string, string>(applications.Length);

            for (int index = 0; index < applications.Length; ++index)
            {
                if (applications[index].StartsWith("{"))
                {
                    dictionary2.Add(applications[index], descriptions[index]);
                }
                else
                {
                    dictionary1.Add(applications[index], descriptions[index]);
                }
            }
            foreach (string key in dictionary2.Keys)
            {
                dictionary1.Add(key, dictionary2[key]);
            }
            return((IDictionary <string, string>)dictionary1);
        }
コード例 #5
0
        /// <summary>
        /// Retrieves the list of existing SSO applications
        /// </summary>
        /// <returns>List of application names</returns>
        public static string[] GetApplications()
        {
            if (Applications == null)
            {
                string[]   descs;
                string[]   contacts;
                ISSOMapper mapper = new ISSOMapper();
                mapper.GetApplications(out Applications, out descs, out contacts);
            }

            return(Applications);
        }
コード例 #6
0
        public void GetVoyagerProperties(string ssoAppName, Hashtable targetTable)
        {
            ISSOMapper mapper = (ISSOMapper) new SSOMapper();

            string[] labels = null;
            int[]    flags  = null;
            mapper.GetFieldInfo(ssoAppName, out labels, out flags);
            for (int i = 0; i < labels.Length; i++)
            {
                targetTable.Add(labels[i], flags[i]);
            }
        }
コード例 #7
0
        /// <summary>
        /// Returns a list of applications in the SSO store
        /// </summary>
        /// <returns>Application names</returns>
        public static List <string> GetApplications()
        {
            //get the app list:
            string[] applications = null;
            string[] descs;
            string[] contacts = null;

            try
            {
                var mapper = new ISSOMapper();

                AffiliateApplicationType appTypes = AffiliateApplicationType.ConfigStore;
                appTypes |= AffiliateApplicationType.All;

                IPropertyBag propBag = (IPropertyBag)mapper;

                uint appFilterFlagMask = SSOFlag.SSO_FLAG_APP_FILTER_BY_TYPE;
                uint appFilterFlags    = (uint)appTypes;

                object appFilterFlagsObj    = (object)appFilterFlags;
                object appFilterFlagMaskObj = (object)appFilterFlagMask;

                propBag.Write("AppFilterFlags", ref appFilterFlagsObj);
                propBag.Write("AppFilterFlagMask", ref appFilterFlagMaskObj);

                mapper.GetApplications(out applications, out descs, out contacts);
            }
            catch (COMException comEx)
            {
                HandleCOMException(comEx, 0);
            }

            List <string> apps = new List <string>();

            if (contacts != null)
            {
                for (int i = 0; i < applications.Length; i++)
                {
                    if (string.Equals(contacts[i], ApplicationManager.ContactInfo))
                    {
                        apps.Add(applications[i]);
                    }
                }
            }

            return(apps);
        }