AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DWT File, Oracle Connection through FDO, Username and Password required

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
thomas.croux
1325 Views, 3 Replies

DWT File, Oracle Connection through FDO, Username and Password required

 

Hello all, Smiley Happy

I have a question about a DWT File containing an FDO Connection to an Oracle Datastore.
Many Final Users share and use a unique DWT file, stored as a file in a database.

Before Final Users can use this DWT file, it needs to be prepared and uploaded into the Database :
1- the Oracle Connection through FDO must be set up in the "Data Connection" Window (Connection Name, Service Name, Username, Password, Datastore, Version).
2- the AutoCAD Map Document must be saved as DWT file.
3- the DWT File must be uploaded into the Customer Database.

My own software, when loaded from AutoCAD Map through NETLOAD command, does the following things automatically :
1- it downloads the DWT file contained in the Database.
2- it creates a new document based on this DWT (all Layers and Features are up and ready to be used).

But I'm facing the following problem: each time a new computer retrieves this DWT File for the first time, when opening it in AutoCAD Map, FDO cannot connect to the data source.
I get the following error :
"L'ouverture de la connexion FDO a échoué."
"ORA-01005: null password given; logon denied"
When I go to the Data Connection, and by clicking on the first "Connect" button, Username and Password are indeed empty.

This is a Security Issue for the final Customer, because :
- only Administrators know the Username and Password,
- Users don't want to be annoyed with this "IT problem", and Administrators don't want to be bothered.

So my question is : what should I do to be sure that the DWT file will connect each time to the datastore, without asking any Username or Password ?

Thanks a lot. Smiley Happy

Best regards,

Thomas.

 

 

[EDIT]

At each start of my own software from AutoCAD Map 3D 2013 using NETLOAD, the same DWT file is automatically downloaded, and replace any existing one with the same name.

3 REPLIES 3
Message 2 of 4
Daniel.Du
in reply to: thomas.croux

Map 3D does not store the username and password for security reason, the connection information is stored in resources, and it can be read/written by API, a better way is to set the username and password before you connect to datasource, it can be done programatically. 

 

Please refer to the sample project Map 3D Resource Explorer to get more information how to read/write resources:

 

  • DevTV : AutoCAD Map 3D Resource Explorer
    A self-paced video tutorial demonstrating AutoCAD Map 3D resources and relevant Geospatial Platform API to access, edit and update them on the fly. 
    View online | Download

https://github.com/ADN-DevTech/map-resource-explorer



Daniel Du
Developer Technical Services
Autodesk Developer Network

Message 3 of 4
MarkVolz4695
in reply to: thomas.croux

Hi Thomas,

 

I was in your situtation a couple of years ago, and there are number of ways around this problem.

Solution 1.

the Autodesk FDO's for databases, store the password in a reg key in the local user area for each connection. So the simplest solution i could find was to simply copy these reg keys prior to the dwt being loaded ... and bingo the problem was solved. However this means that each user/machine combo will need to load the reg key(s), it also present some interesting security issues. The other problem is that by using this method there is occasionally caching issues with the returned data sets, so the mapcache folder should be cleaned up between drawings.

 

Solution 2.

This solution removes the need to have FDO layers in your DWT file. You say that you have developed an app in .net so I assume you now the Dll's & namespaces for the AcMap classes. The AcMapMap.GetCurrentMap().LoadLayer("filepath of .layer") function gives you ability to load an exported version of your layer, which will automatically create your database connection if it doesn't exist, and the files are simple to make, just right click on the fdo layer and select the "save layer" option. So the process i developed was to a) use autocad map to create all the .layer files, and b) then creat a command to loop through and load all the .layer files in a folder. Later on I built a dialog box which allowed the user to pick which .layer they wanted to load.

 

Solution 3. (where i am now)

If you look at the .layer files you will see that they are actually just xml files, and coupled with the info in the below devblog you will find that you can bypass making multiple .layer files and just create 1 xml file and then load the layers out of it. You can also modify the query for the layer prior to adding it to the map. Here is the dev article http://adndevblog.typepad.com/infrastructure/2013/03/autocad-map-3d-api-training-content-part-2.html . I prefer to work directly with the xml rather then the classes (as you will see in the below snippets) but both work.

 

Below is the code to get the xml definition of an FDO connection (Any FDO connection) for every layer in the map.

 

                MgLayerCollection layers = AcMapMap.GetCurrentMap().GetLayers();
                foreach (AcMapLayer layer in layers)
                {
                    //get the data connection details for the layer
                    MgResourceIdentifier dataid = new MgResourceIdentifier(layer.FeatureSourceId);
                    AcMapResourceService dataServ = AcMapServiceFactory.GetService(MgServiceType.ResourceService) as AcMapResourceService;
                    MgByteReader datareader = dataServ.GetResourceContent(dataid);
                    //show the xml for the data connection
                    MessageBox.Show(datareader.ToString());
}

Here is a function to build a connection given a string of xml (from above code: datareader.toString()) and the name you want to call the connection:

 private void create_con(string dataConn, string name)
        {
            AcMapResourceService rs = AcMapServiceFactory.GetService(MgServiceType.ResourceService) as AcMapResourceService;
            AcMapFeatureService fs = AcMapServiceFactory.GetService(MgServiceType.FeatureService) as AcMapFeatureService;
            MgResourceIdentifier fsId = new MgResourceIdentifier(name);
            byte[] unicodeBytes = Encoding.Unicode.GetBytes(dataConn);
            byte[] utf8Bytes = Encoding.Convert(Encoding.Unicode, Encoding.UTF8, unicodeBytes);

            MgByteSource xmlsource = new MgByteSource(utf8Bytes, utf8Bytes.Length);

            try
            {
                rs.SetResource(fsId, xmlsource.GetReader(), null);
                fs.GetSchemas(fsId);
            }
            catch (MgException me)
            {
                MessageBox.Show("An error occured creating data source " + name + ".\nMessage reads;\n" + me.Message, "Error creating FDO connection");
            }
            

        }

 

There are similar functions to export & load a layer definition as well.

 

Hope this helped & didn't confuse the issue.

 

Mark

 

Message 4 of 4
thomas.croux
in reply to: MarkVolz4695

Dear Mark,

 

I would like to thank you so much for this fabulous message.

Sorry for delay, I was in a hurry last days.

I will analyze your different solutions, and I will provide you some feeback about my results.

Thank you very very much !!

 


Best regards,

 

thomas.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost