I need to make a web directory from an AD. However, I must exclude a portion of the tree in my results.
To schematize the structure:
-Telephony
----Special
----Users
----Other
I would like to exclude OU=Special. Or target OU=Users and OU=Other, but without having to write a line by "OU".
I went round and round about the query options, I'm here but that does not exclude the group.
$ldap = Ldap::create('ext_ldap', array(
'host' => 'XXX.XXX.XXX.XXX',
));
$ldap->bind('dn', 'password');
$query = $ldap->query('ou=Telephony,ou=XXXX,dc=XXXX,dc=XXXX,dc=XXXX,dc=XXXX', '(cn=*)', ['filter' => '|(ou=Users*)(ou=Other*)']);
But I still get the data from Special.
How can I make this filter?
Thank's for help
That depends.
Defined in LDAPv3 RFC 2254 an ExtensibleMatch search filter requires LDAP servers to recognize a search element called an extensible match filter.
A ExtensibleMatch search filter would allow this however, ExtensibleMatch search filter is NOT supported by all LDAP Vendors. (Microsoft Active Directory as one example).
For your example, a filter similar to:
(&(|(ou:dn:=Users)(ou:dn:=Others))(objectclass=inetorgperson)(sn=willeke))
May work.
Related
Good Evening Devs,
I'm trying to skip the first index of the array while applying validation rule and this is what I tried so far
$validatedData = Validator::make($request->all(),([
'inventories.0' => 'bail',
'inventories' => 'required|array|filled',
'quantities.0' => 'bail',
'quantities.*' => 'required|array|filled',
'required.0' => 'bail',
'required.*' => 'required|array|filled',
]));
But it's not working, any ideas?
I'm trying to add multiple dynamic fields, but want to skip the first index of it.
Please review the picture given below to get the clear picture of the problem.
try this:
$validatedData = Validator::make($request->except(['inventories[0],quantities[0],required[0]']),([
'inventories.*' => 'required|array|filled',
'quantities.*' => 'required|array|filled',
'required.*' => 'required|array|filled',
]));
Bail is not used for skipping an entry. But it may be used for skipping validation logic.
for example,
'phone' => 'bail|numeric|unique:users'
In this case, if somehow the entered phone number is not numeric, it will not check the third validation (i.e. whether the phone number is unique in 'users' table or not).
For your case, you should not use "$request->all()". You should use "request()->except(['inventories[0], quantities[0], required[0]'])" instead
This is perhaps, not the best practice. You're trying to allow the presentation layer to have a direct influence over the data / logic layer of your application. It would probably be better to only send over the data you want to validate rather than sending over everything and they tying to get your validation (and other logic) to ignore the first array element.
Is it an api call or a standard web form you are submitting? If it is an api call, can you not build up your data of only the rows you want to send over, before you make the call?
This will keep your logic layer much cleaner, and allow you to change the ui much easier without affecting the logic, and it being tightly coupled.
Just a suggestion.
I've created a couple of pages they are users, groups and permissions.
I would like the admin to be able to create groups and set what those groups can do via the permissions page.
So on the permissions page I would have a list of things a user could do e.g.: add content, delete content.
And if I check the add content box then the group can only add content and not delete content.
The problem I'm having is that I don't know where to go to look for information on how to go about it. I've already got my database set up and I'm thinking maybe sessions and routes is the way to go, but I'm not sure.
Frameworks is the way to go for something this complex. I'm working on a very similar project for my work (a dashboard to do different things based on User Role/Permissions) and I found it incredibly difficult to manage without the use of a framework. I would highly recommend Cartalyst/Sentry for this. It turns complex database operations like checking permissions, update permissions, creating groups etc into simple one. Here is a link to the manual:
Cartalyst/Sentry
It has a database backend already created (and modifiable) for you, so you simply follow the installation instructions and go over the documentation to get a better understanding. In your example, it would be as simple as creating a group and it's permissions:
// Define permissions (1 is allowed, 0 is not allowed)
$permissions = array('content.create' => 1, 'content.delete' => 1, etc etc...));
$group = Sentry::createGroup(array('name' => 'Admin', 'permissions' => $permissions));
Creating a user and adding them to the group:
$user = Sentry::createUser(array('email' => 'test#test.com', 'first_name' => ..., etc));
$group = Sentry::findGroupByName('Admin');
$user->addGroup($group);
And then checking their permissions during routing:
$user = Sentry::check(); // Aka get the current user.
if($user->hasAccess('content.create'){
// Continue
} else {
// Redirect to error page, etc
}
Now that's a brief overview of the system, and I assume you know how to use controllers and routes, but play around with it and I'm sure you'll come to see how powerful this Framework is when working with Laravel.
Hope that helps!
Then checking whether or not a user
I am executing a raven query in C#, and utilising both the Where() and Search() extension methods.
I need both these functionalities, because I need to only return indices with a specific Guid field, AND text that exists in a body of text.
Unfortunatly, the Where extension method seems to not be compatible with the Search extension method. When I combine them I get a Lucene query like this:
Query: FeedOwner:25eb541c\-b04a\-4f08\-b468\-65714f259ac2 MessageBody:<<request*>>
Which seems to completely ignore the 'MessageBody' part of the criteria - so it doesnt matter what constraint I use in the 'free text', it doesnt use it.
I have tested with the 'Search' alone, and it works - so its not a problem with free-text searching by itself - just combining the two.
Thanks to #Tobias on Raven#GoogleGroups who pointed me in the right direction - there was an option to define how the Where and Search clauses would be combined:
Query<T>.Search(candidate => candidate.MessageBody, queryString + "*", options: SearchOptions.And);
I'm not sure if this is the best way to go about this, but my aim is to have pagination of my lucene search results.
I thought it would make sense to run the search, store all the results in the cache, and then have a page function on my results controller that could return any particular subset of results from the cached results.
Is this a bad approach? I've never used caching of any sort, so don't know where to begin. The CI Caching Driver looked promising, but everything throws a server error. I don't know if I need to install APC, or Memcached, or what to do.
Help!
Lucene is a search engine that is built for scale. You can push it pretty far till the need arises to cache the search results. I would suggest you use the default settings and run it.
If you still feel the need for cache, first look at this Lucene FAQ and then the next level would perhaps be something on the lines of memcache.
Hope it helps!
Zend Search Lucene is indexed on the file system and as the user above has stated, built for scale. Unless you are indexing hundreds of thousands of documents, then caching is not really necessary - especially since all you would effectively be doing is taking data from one file and storing it in another.
On the other hand, if you are only storing, say, product Id in your search index and then selecting the products from the database when you get a result, it's well worth caching. This can easily be achived by using Zend_Cache.
A basic example of Zend Db caching is here:
$frontendOptions = array(
'automatic_serialization' => true
);
$backendOptions = array(
'cache_dir' => YOUR_CACHE_PATH_ON_THE_FILE_SYSTEM,
'file_name_prefix' => 'my_cache_prefix',
);
$cache = Zend_Cache::factory('Core',
'File',
$frontendOptions,
$backendOptions
);
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
This should be added to your bootstrap file in an _initDbCache (call it whatever you want) method.
Of course that is a very simple implementation and does not achieve full result caching, more information on Zend Caching with Zend Db can be found here.
I am using ruby's net/ldap library for this problem but in reality the driver language shouldn't really matter. I need to find a way to be able to get all the users from a system and find out which users do not have emails assigned to the account. Is it possible?
I can connect to and even create new records through LDAP, and can return queries by using wildcard entries to filter results.
given i create a filter to find the cn that begins with three 9's:
filter = Net::LDAP::Filter.eq("cn", "999*")
#connection.search(:base => "cn=Manager, dc=foo, dc=bar, dc=biz",
:filter => filter)
then my result count might be 42.
given i create the same filter but request only 1 nine, the query fails and returns false
filter = Net::LDAP::Filter.eq("cn", "9*")
#connection.search(:base => "cn=Manager, dc=foo, dc=bar, dc=biz",
:filter => filter)
and this is the same if I request just "cn", "*" which to me should say "give me all the cn's out there.
".
So the short answer to the question is that it all depends on how your schema is setup. If you are setting up an LDAP schema, you need to have several groups of records with various cn (common name) identifiers, eg cn=activeUsers and cn=inactiveUsers which will allow you to query down the list much deeper than in my situation.
I think that you have an issue with time limit set on search operations at the LDAP server.
If you have a really big search that takes much time, the LDAP server returns an error 'Time limit exceeded' and no data.
Ruby-Ldap in such a case raises an exception LDAP::ResultError. I don't know how Net-Ldap behaves however.
Try to raise the time limit at your LDAP server or use a tighter search filter such as '(&(cn=9*)(active=TRUE))'. Substitute here 'active=TRUE' with your criteria for active users.