on 11-27-2007 3:23 PM
We have installed NetWeaver 2004s, MDM and business package for MDM.
Our task is to obtain access to MDM repository from our custom components (i.e WebDynpro components).
All solutions founded on the SAP SDN have hard-coded credentials (login and password) in code or in *.properties file (example described here https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/506c9e5f-3a7d-2910-fe97-cc1a733f....
But our component will work under NetWeaver which means in already authenticated context and we would like to use it for MDM connection rather than hard-coded credentials. Can we use already configured in NetWeaver "MDM System" for authentication reason?
If anyone can helps, please answer.
Thank you.
Yes. In your WebDynpro code you can read from the user mapping for the user running the application. Since you have the MDM Business Package create a MDM System, and for each user setup the user mapping to the MDM System in the User Administration area. Your web dynpro code can read the user name and password stored for this MDM System for the user. You will have to hard code the MDM System name or put it in a properties file, but it is better than hard coding user names and passwords. Search SDN for how to read user system mapping data, I know it is out there, but I don't have a link. This is standard Netweaver code, not MDM specific code, so don't just look in the MDM forum.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You won't be able to get a UserSession from the mapping, but once you have the user name and password you can use them in any way the examples used the hard coded user name and password. Here is some code I wrote previously for this, you will have to make the com.sap.security.sap.sda a used DC and change the LocalMDM to the system name you create.
ArrayList systemLandscapes = UMFactory.getSystemLandscapeWrappers();
try {
ISystemLandscapeWrapper systemLandscape =
(ISystemLandscapeWrapper) systemLandscapes.get(0);
IUserMapping userMapping = UMFactory.getUserMapping();
IAuthentication a = UMFactory.getAuthenticator();
IUser user = a.getLoggedInUser();
mm.reportSuccess("Current user: " + user.getUniqueName());
ISystemLandscapeObject MDMSystem =
systemLandscape.getSystemByAlias("LocalMDM");
IUserMappingData mappingData =
userMapping.getUserMappingData(MDMSystem, user);
HashMap hash = new HashMap();
try {
mappingData.enrich(hash);
} catch (NoLogonDataAvailableException e1) {
// TODO Auto-generated catch block
mm.reportException(
"Error1: " + e1.getLocalizedMessage(),
false);
}
String userString, passString;
if (hash.get(IUserMappingData.UMAP_USER) != null) {
userString = hash.get(IUserMappingData.UMAP_USER).toString();
} else {
userString = null;
}
if (hash.get(IUserMappingData.UMAP_PASSWORD) != null) {
passString =
hash.get(IUserMappingData.UMAP_PASSWORD).toString();
} else {
passString = null;
}
mm.reportSuccess(
"MDM user: " + userString + " MDM pass: " + passString);
} catch (ExceptionInImplementationException e) {
// TODO Auto-generated catch block
mm.reportException("Error2: " + e.getLocalizedMessage(), false);
}
Thank`s a lot for your example. So, with your example:
1) I have real user\password for repository
2) I have MDM server name from MDMSystem.getAttribute("Server")
3) I have repository name from MDMSystem.getAttribute("RepositoryName").
With this data, i can get connection ConnectionPoolFactory.getInstance(serverName). But
to create user session (CreateUserSessionCommand) i need RepositoryIdentifier instance. The constructor of RepositoryIdentifier needs repositoryName, dbmsServer and dbmsType parameters. I have only repositoryName.
Is it possible to get from MDMSystem info about repository dbmsServer and dbmsType?
Or, maybe, is there another way to use MDMSystem with MDM JAVA API 2?
DBMS type is necessary only during RepositoryIdentifier object creation, but you can retrieve list of repositories from server and get your one from this list.
I do it in this way:
private RepositoryIdentifier getRepositoryIdentifier(ConnectionAccessor connection, String repositoryName) {
GetMountedRepositoryListCommand command = new GetMountedRepositoryListCommand(connection);
try {
command.execute();
} catch (CommandException e) {
log(e);
return null;
}
RepositoryIdentifier[] repositories = command.getRepositories();
for (int m = 0; m < repositories.length; m++) {
if (repositories[m].getName().equalsIgnoreCase(repositoryName)) {
return repositories[m];
}
}
return null;
}
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.