How to add geolocation attributes to an LDAP account - geolocation

I have an LDAP users database mapped as objects of class posixAccount, inetOrgPerson and top.
I need to add latitude and longitude attributes to the users. However, theses attributes do not seem to be present on these classes (and also not in others). inetOrgPerson presents only references such as postalAddress, street, etc.
Is it possible to add a new class or a new attribute to an existing LDAP class? Or is there any other solution path I'm missing?
I'm using openldap server with phpldapadmin (although these are not hard constraints).
Thanks a lot,
alan

While it's possible to add attribute types to a standard (RFC) object class, you shouldn't do that. The vCard-4.0 draft conveniently defines an attribute latLong (section 3.14). You create an auxiliary objectClass with that attribute type that you later can use to add GPS coordinates to your entries.
Create a file "geolocation.schema" like:
# latLong
# Represents a geographical location using the WGS84 data coordinates
# as used by GPS, like: -33.92;151.28
attributetype ( 1.3.6.1.4.1.33592.1.3.14 NAME 'latLong'
EQUALITY caseIgnoreMatch
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
)
# geoLocation
# The geoLocation auxiliary class allows GPS coordinates to be added
# to an object
objectclass ( your-company-oid-prefix-as-provided-by-IANA.your-oc-convention
NAME 'geoLocation'
DESC ''
AUXILIARY
MAY ( latLong )
)
In your slapd.conf file add an include statement for your schema file. The new object class is available after you restart the LDAP server.
If your organization doesn't already have an OID prefix, get one. For tests you can fake one.
Typed and not tested...

Related

Handling conditions at class level based on association

I'm not sure how to frame this question, I am looking to solve a design problem.
I'm using ActiveRecord.
An Agency can have multiple documents.
documents has a column additional_details of type jsonb. Contains hash details.
additional_details column has different set of key value pair based on agency.
Example:
doc1 = agency1.documents.first.additional_details => { xml_url: '', ... }
doc2 = agency2.documents.first.additional_details => { feed_url1: '', ... }
agency1 and agency2 are instance objects of Agency.
When I make a call to fetch the url like document.additional_details.get_url
I can write conditions like
def get_url
if agency1.name == 'Utah'
return additional_details[xml_url]
elsif
so on
elsif
so on
end
end
Which is not a good practice I feel.
I believe we can solve this at class level. Note I need to solve this on presentation layer, I'm using decorators .
Edit:
An particular agency will have same keys within additional_details column but values are certainly different.
I am assuming these are Active Record classes? Where is agency1 defined? You should almost never be hard coded based on specific instances, instead any such data should be part of the record and its instance.
It is especially unclear why you have different types of "URL" at all, and not just a simple url string column in the documents table. Why does agency1 use xml_url but agency2 uses feed_url1?
But as an example, if each agency has say a prefix defined (say the domain name / filestore, and the documents just the relative/local address), say:
agency1.document_root = "https://example.com/documents/"
agency1.documents.first.rel_url = "web/rails/rails_example.pdf"
Then in the Document class you might do:
def url
agency.document_root + rel_url
end
Which then gives you the:
agency1.documents.first.url
Add a field to your Agency model where you store the key to the url in the additional data hash. Let's say you name the field url_key. Then you can do
def get_url
additional_details[agency.url_key]
end
Note that I assume that get_url is a method on the Document model.

Manipulating location is failing because of < and > in location

I have a location
|java+class:///smallsql/database/CommandDrop|(114,115,<3,68>,<8,5>)
which I would like to convert to
|project://SmallSQL/src/smallsql/database/CommandDrop.java|(114,115,<3,68>,<8,5>).
I want to do this by using toString, then manipulate the resulting String and then apply a toLocation. However, this is failing because toString will turn < into \< and similar for >. Now toLocation will see it as a malformed URI. Anyone any idea?
If you want to manipulate a path of a location, keeping the rest the same, just do it like this:
myLoc.path = myManipulation(myLoc.path);
where myManipulation is a function.
But to me it seems you just want to resolve the logical location to a physical one:
import IO;
myLoc = resolveLocation(myLoc);
Mind you, the project's M3 model must have been registered before using analysis::m3::Registry::registerProject otherwise the resolution won't work.
You can also directly look up the path you need by looking it up in the M3 model's declarations table.

when to use globalIdField

As far as I can tell, relay relies on nodeDefitions for queries when variables are being changed.
It'd appear that all objects with an id field should be a valid node. However, if I have data like this:
type User {
id: globalIdField('User'),
name: String,
folders: [ Folder ]
}
type Folder {
id: ???,
...
}
The data is stored in a document based solution, and the Folder objects are nested in the User object. But Folder objects are given an id so that some other objects could reference the Folder objects under the context of a User.
If Folder implements the nodeInterface, and uses globalIdField, then I need to figure out a way to fetch the Folder object from a globalId, meaning that I might have to scan through all the Users to find it, have a data map that'd allow me to find the object, or normalize the data so that Folders are in their own table.
If it doesn't implement the nodeInterface, and just uses Strings as id field, what happens when I try to mutate some fields on the Folder object?
It's often useful for these objects to have ids, even if there's no real id directly in your database. For example, if you want to write a mutation to rename a folder, it'd be great to have a global ID to reference this folder. Relay also uses them internally when the UI requests some additional data on a node that's not loaded yet.
One way to generate a global ID for the folder could be to take a prefix and add the user id and a way to identify the folder within the user, for example:
var folderID = ['folder', userID, folderID].join(':');
Whenever you want to resolve this id on your server, you split at the :, see that you want to load a folder by looking at the first part and then go via user to the right folder.

How can sqlpackage.exe perform schema compare only on stored procedures?

In VS 2012, the schema compare tool let's users compare only "stored procedures" by selecting the option "stored procedures" as the application scoped object.
Is there a way to perform schema compare only on the selected schema object using SqlPackage.exe?
Have a look at the latest documentation. They have added a /p:ExcludeObjectTypes={string} property and you can specify a semi-colon delimited list.
Just add all Object Types except Stored Procs.
Example /p:ExcludeObjectTypes=Tables;Views;
Valid object type names are Aggregates
ApplicationRoles
Assemblies
AsymmetricKeys
Audits
BrokerPriorities
Certificates
ClrUserDefinedTypes
Contracts
Credentials
CryptographicProviders
DatabaseAuditSpecifications
DatabaseRoles
DatabaseTriggers
Defaults
Endpoints
ErrorMessages
EventNotifications
EventSessions
ExtendedProperties
Filegroups
FileTables
FullTextCatalogs
FullTextStoplists
LinkedServerLogins
LinkedServers
Logins
MessageTypes
PartitionFunctions
PartitionSchemes
Permissions
Queues
RemoteServiceBindings
RoleMembership
Routes
Rules
ScalarValuedFunctions
SearchPropertyLists
Sequences
ServerAuditSpecifications
ServerRoleMembership
ServerRoles
ServerTriggers
Services
Signatures
StoredProcedures
SymmetricKeys
Synonyms
Tables
TableValuedFunctions
UserDefinedDataTypes
UserDefinedTableTypes
Users
Views
XmlSchemaCollections

Grails : how to customize order with a sql function?

I want to retrieve the 10 nearest geolocalized objects using Gorm.
To do so, I would like to customize the order() parameter in order to use a get_distance(longitude, latitude, :longitude, :latitude) sql function.
I've been struggling with this all day, does anybody have a hint ?
Thanks !
EDIT
I finally managed to do what I wanted but with a very ugly solution :
I added a sqlProjection in which I put my get_distance() function and was able to order by it.
Adding a projection removes the retrieval of the object properties so I had to explicitly ask for it by adding property projections and I managed to do it with introspection.
Then I had to define the result transformer of the criteria for it to give me domain instances.
If register your function with the hibernate SQL dialect, then you can use it in HQL queries. For example, put this in your bootstrap code:
import org.hibernate.dialect.function.SQLFunctionTemplate
import org.hibernate.Hibernate
def dialect = applicationContext.sessionFactory.dialect
def getDistance = new SQLFunctionTemplate(Hibernate.INTEGER, "get_distance(?1,?2)")
dialect.registerFunction('get_distance', getDistance)
Then you can use it in HQL:
Location.executeQuery(
"""
select id, get_distance(latitude, longitude) as distance
from Location
order by distance
""",
[], [max: 10])
What we did is the following:
Create the query with whatever DB specific operators, but as a view
Create a new domain class object solely to map to the view, thereby allowing you to do GORM criteria queries and the like

Resources