public string ResetPasswordAndRedirect(BOPasswordReset passwordReset) { SessionInfo objInfo = new SessionInfo(); string errorMessage = ""; try { using (SessionPortClient objClient = new SessionPortClient("BOSession")) { _logMessages.AppendFormat("Performing password reset for user:{0}.", passwordReset.Username); if (passwordReset.AccountLocked) { _logMessages.AppendFormat("Account locked.Performing change password for user:{0}.", passwordReset.Username); objClient.changePassword(passwordReset.SAPLoginToken, passwordReset.OldPassword, passwordReset.NewPassword); } else { EnterpriseCredential creds = new EnterpriseCredential(); creds.Login = passwordReset.Username; creds.Password = passwordReset.OldPassword; creds.AuthType = "secEnterprise"; _logMessages.Append("Performing logon to the sap BO"); objInfo = objClient.login(creds, ""); if (objInfo != null) { objClient.changePassword(objInfo.SessionID, passwordReset.OldPassword, passwordReset.NewPassword); } } } } catch (System.Exception ex) { errorMessage = ex.Message; _logMessages.AppendFormat("Error occurred in password reset. Exception message {0}.", ex.Message); _logger.Info(_logMessages.ToString()); return(errorMessage); } _logger.Info(_logMessages.ToString()); return(errorMessage); }
public BOAuthentication AuthenticateUserAndGetToken(BOAuthentication authModel) { EnterpriseCredential creds = new EnterpriseCredential(); SessionInfo objInfo = new SessionInfo(); using (SessionPortClient objClient = new SessionPortClient("BOSession")) { try { creds.Login = authModel.UserName; creds.Password = authModel.Password; creds.AuthType = authModel.UserAuth; _logMessages.AppendFormat("Performing logon with username {0} and authentication type {1}.", authModel.UserName, authModel.UserAuth); objInfo = objClient.login(creds, string.Empty); if (objInfo != null) { authModel.StatusCode = 0; // concatenate with double quotes and store as member authModel.LogonToken = "\"" + objInfo.DefaultToken + "\""; authModel.MustChangePassword = objInfo.MustChangePassword; authModel.BOSesssionID = objInfo.SessionID; authModel.BOSerializedSessionId = objInfo.SerializedSession; _logMessages.AppendFormat("Logon successfull for the user {0}.", authModel.UserName); } else { _logMessages.Append("Logon failed for an unknown reason."); authModel.StatusCode = 4; } _logger.Info(_logMessages.ToString()); return(authModel); } catch (System.Exception ex) { _logMessages.AppendFormat("Error occurred during logon {0}.", ex.Message); _logger.Info(_logMessages.ToString()); throw; } } }
public UniDocument() { Connection boConnection = new Connection(@"http://watchmen:8080/dswsbobje/services/session"); EnterpriseCredential boCredential = new EnterpriseCredential(); boCredential.Domain = "watchmen"; boCredential.AuthType = "secEnterprise"; boCredential.Login = "******"; boCredential.Password = ""; Session_ boSession = new Session_(boConnection); SessionInfo boSI = boSession.Login(boCredential); string[] strBOQuerySrvURL = boSession.GetAssociatedServicesURL("QueryService"); if (strBOQuerySrvURL.Length == 0) { throw new Exception("QueryService not found"); } QueryService boQuerySrv = QueryService.GetInstance(boSession, strBOQuerySrvURL[0]); DataSource[] boUniverses = boQuerySrv.GetDataSourceList(); String boUniverseUID = boUniverses[0].UID; DataSourceSpecification boUniverseSpecification = boQuerySrv.GetDataSource(boUniverseUID); DataSourceClass[] boDataSourceClasses = boUniverseSpecification.DataSourceClass; Hierarchy[] boHierarchy = boUniverseSpecification.Hierarchy; ArrayList detailKeyList = new ArrayList(); ArrayList dimensionKeyList = new ArrayList(); ArrayList measureKeyList = new ArrayList(); ArrayList preConditionObjectKeyList = new ArrayList(); for (int i = 0; i < boDataSourceClasses.Length; i++) { DataSourceObject[] boDataSourceObjects = boDataSourceClasses[i].DataSourceObject; for (int j = 0; j < boDataSourceObjects.Length; j++) { if (boDataSourceObjects[j] is Detail) { detailKeyList.Add(boDataSourceObjects[j].Key); } if (boDataSourceObjects[j] is Dimension) { dimensionKeyList.Add(boDataSourceObjects[j].Key); } if (boDataSourceObjects[j] is Measure) { measureKeyList.Add(boDataSourceObjects[j].Key); } if (boDataSourceObjects[j] is PreConditionObject) { preConditionObjectKeyList.Add(boDataSourceObjects[j].Key); } } } ArrayList scopeKeyList = new ArrayList(); for (int k = 0; k < boHierarchy.Length; k++) { DataSourceObject[] boScopeObjects = boHierarchy[k].DataSourceObject; for (int m = 0; m < boScopeObjects.Length; m++) { scopeKeyList.Add(boScopeObjects[m].Key); } } Object[] dimensionKeys = dimensionKeyList.ToArray(); Object[] detailKeys = detailKeyList.ToArray(); Object[] measureKeys = measureKeyList.ToArray(); Object[] preConditionObjectKeys = preConditionObjectKeyList.ToArray(); Object[] scopeKeys = scopeKeyList.ToArray(); boSession.Logout(); }