public static InfoMgr getMgr(String type, IPTSession iptsession) { if (type.Equals(Constants.WEBSERVICES)) { return (InfoMgr) (new WSInfoMgr(iptsession)); } else if (type.Equals(Constants.PORTLET)) { return (InfoMgr) (new PortletInfoMgr(iptsession)); } else if (type.Equals(Constants.COMMUNITY)) { return (InfoMgr) (new CommunityInfoMgr(iptsession)); } else if (type.Equals(Constants.COMMUNITYPAGE)) { return (InfoMgr) (new CommunityPageInfoMgr(iptsession)); } //default to at least return a webservices manager. else { return (InfoMgr)(new WSInfoMgr(iptsession)); } }
/// <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; }
public CommunityPageInfoMgr(IPTSession _ptSession) { this.ptSession = _ptSession; }
// private Hashtable PROP_BAG_PROPS; // private int URL_PROP = 106; private bool getSession() { try { if (session != null) return true; IOKContext okContext = OKConfigFactory.createInstance(txtConfig.Text, "portal"); PortalObjectsFactory.Init(okContext); session = PortalObjectsFactory.CreateSession(); session.Connect(txtUser.Text, txtPass.Text, null); } catch (Exception ex) { MessageBox.Show("Exception getting session: " + ex.Message + Environment.NewLine + ex.StackTrace); } return true; }
/// <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; }
/// <summary> /// This function loops through the portal and finds all properties which are lock boxes /// (either user names or passwords). It prints out their IDs -- it could probably used with the above to /// grab actual info from the properties. /// </summary> /// <param name="session">The user session to use for finding the properties.</param> public static void GetLockBoxProperites(IPTSession session) { IPTObjectManager profilePageObjMgr = session.GetProfilePages(); IPTObjectManager profileSectionObjMgr = session.GetProfileSections(); PTObjectManagerQueryWrapper omqw = new PTObjectManagerQueryWrapper(profilePageObjMgr); Object[][] queryFilter = PlumtreeHelpers.GetQueryFilter(PT_PROPIDS.PT_PROPID_OBJECTID, PT_FILTEROPS.PT_FILTEROP_EQ, PT_INTRINSICS.PT_PROFILE_PAGE_CREDENTIAL_VAULT); omqw.Query(PT_PROPIDS.PT_PROPID_OBJECTID, -1, null, queryFilter); if (omqw.GetCount() > 0) { IPTProfilePage page = (IPTProfilePage) profilePageObjMgr.Open(1, false); object[] lockboxes = page.GetChildSections(); for (int i = 0; i < lockboxes.Length; i++) { int lockBoxId = (int) lockboxes[i]; IPTProfileSection profileSection = (IPTProfileSection) profileSectionObjMgr.Open(lockBoxId, false); Object[] arPropIDs = profileSection.GetChildProperties(); if (arPropIDs.Length >= 2) { Console.WriteLine(XPConvert.ToInteger(arPropIDs[0])); Console.WriteLine(XPConvert.ToInteger(arPropIDs[1])); } } } }