示例#1
0
        /// <summary>
        /// Using any session, pass a user ID to decrypt all encrypted properties for this user.
        /// </summary>
        /// <param name="session">Session to use for decryptioin.</param>
        /// <param name="userId">User ID to decrypt properties for.</param>
        /// <returns></returns>
        public static SortedList EncryptedProperties(IPTSession session, int userId)
        {
            SortedList list = new SortedList();

            IPTProfileManager manager = (IPTProfileManager) session.OpenGlobalObject(PT_GLOBALOBJECTS.PT_GLOBAL_PROFILE_MANAGER, false);
            IPTUserInfo info = manager.GetUserInfo(userId);

            // find properties that are encrypted
            IPTObjectProperties userProps = manager.GetUserProperties(userId, false);
            IPTQueryResult result = userProps.GetPropertyData(PT_PROPIDS.PT_PROPID_ALL);

            for (int i = 0; i < result.RowCount(); i++) {
                // you could take out the if statement below and you'd get *all* properties for the user
                //Console.WriteLine(result.ItemAsInt(i, PT_PROPIDS.PT_PROPID_OWNERID));
                if (result.ItemAsInt(i, PT_PROPIDS.PT_PROPID_PROP_VALUETYPE) == PT_PROPERTY_TYPES.PT_PROPTYPE_ENCRYPTED) {
                    //Console.WriteLine(result.ItemAsString(i, PT_PROPIDS.PT_PROPID_NAME) + " - " + result.ItemAsString(i, PT_PROPIDS.PT_PROPID_PROP_VALUE) );
                    string settingName = result.ItemAsString(i, PT_PROPIDS.PT_PROPID_NAME);
                    string settingUUID = result.ItemAsString(i, PT_PROPIDS.PT_PROPID_MIGRATION_UUID);
                    Console.WriteLine(settingName + " = " + info.GetSetting(settingUUID));
                }
            }

            return list;
        }
示例#2
0
        /// <summary>
        /// List properties in the portal
        /// </summary>
        /// <param name="session">Session to use for propety listing.</param>
        /// <returns></returns>
        public static SortedList ListProperties(IPTSession session)
        {
            SortedList list = new SortedList();

                //get all the properties for this user
                IPTProfileManager pm = (IPTProfileManager) session.OpenGlobalObject(PT_GLOBALOBJECTS.PT_GLOBAL_PROFILE_MANAGER, false);
                bool bRequestEdit = true;
                IPTObjectProperties profileEOD = pm.GetUserProperties(session.GetSessionInfo().GetCurrentUserID(), bRequestEdit);

                //put all the properties in a hashtable, indexed by object id
                XPHashtable profileData = new XPHashtable();

                XPArrayList valList;
                int propertyIndex;

                // First get non-reference property data
                IASQueryResult profileQR = GetObjectPropData(profileEOD);

                propertyIndex = 0;

                while (propertyIndex < profileQR.GetCount()) {
                    // get value type
                    valList = GetAllValues(profileQR, propertyIndex);
                    profileData.RemoveElement(profileQR.GetFields(propertyIndex, PT_PROPIDS.PT_PROPID_OBJECTID));
                    profileData.PutElement(profileQR.GetFields(propertyIndex, PT_PROPIDS.PT_PROPID_OBJECTID), valList);

                    list.Add(profileQR.GetFields(propertyIndex, PT_PROPIDS.PT_PROPID_OBJECTID), profileQR.GetFields(propertyIndex, PT_PROPIDS.PT_PROPID_PROP_VALUETYPE));

                    if (valList.GetSize() == 0) {
                        break;
                    }

                    propertyIndex += valList.GetSize();
                }

                IASQueryResult profileRefQR = GetObjectPropRefData(profileEOD);
                propertyIndex = 0;

                while (propertyIndex < profileRefQR.GetCount()) {
                    // get value type
                    valList = GetAllValues(profileRefQR, propertyIndex);
                    profileData.RemoveElement(profileRefQR.GetFields(propertyIndex, PT_PROPIDS.PT_PROPID_OBJECTID));
                    profileData.PutElement(profileRefQR.GetFields(propertyIndex, PT_PROPIDS.PT_PROPID_OBJECTID), valList);

                    list.Add(profileRefQR.GetFields(propertyIndex, PT_PROPIDS.PT_PROPID_OBJECTID), profileRefQR.GetFields(propertyIndex, PT_PROPIDS.PT_PROPID_PROP_VALUETYPE));

                    if (valList.GetSize() == 0) {
                        break;
                    }

                    propertyIndex += valList.GetSize();
                }
            // profile data
            return list;
        }