开发者

Error searching directory with ODQuery

I'm trying to search an LDAP database using the ODQuery method. I have the following code set up:

- (void)awakeFromNib
{
[self startSearch:@"john"];
}

- (void)startSearch:(NSString *)searchString
{
nodeName = @"http://sububria.org.au";
session = [ODSession defaultSession];
searchNode = [[ODNode alloc] init];
searchNode = [ODNode nodeWithSession:session name:nodeName error:NULL]; 

query = [[ODQuery alloc] initWithNode:searchNode
                       forRecordTypes:kODRecordTypePeople
                            attribute:kODAttributeTypeAllAttributes
                            matchType:kODMatchInsensitiveContains
                          queryValues:searchString
                     returnAttributes:kODAttributeTypeAllAttributes
                       maximumResults:0
                                error:NULL];

[query setDelegate:self];
[query scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
}

- (void)query:(ODQuery *)inSearch foundResults:(NSArray *)inResults error:(NSError *)inError
{ 
NSLog (@"Search ran");
NSLog (@"%@", inResults);
}

I'm pretty new to this so I'm not sure what I could be doing wrong. I'm not getting any warnings or errors in Xcode, my app is just crashing when the search query is run.

There is no console error that a开发者_运维问答ppears, but the most recent items in the thread stack are;

CFRetain
_ODQueryInitWIthNode
-[ODQuery initWithNode:forRecordTypes:attribute:matchType:queryValues:returnAttributes:maximumResults:error:]
-[MyAppDelegate startSearch:]
-[MyAppDelegate applicationDidFinishLaunching:]

I'd appreciate any help. Ricky.


All you've done is create a query; you haven't actually started a search.

To search synchronously, ask the query for all the results at once. If you pass NO (meaning return all the results), this may take a while.

To search asynchronously and get informed whenever it has more results for you, be the query's delegate and then schedule the query on a run loop.

Edit: Also, I doubt “http://server.org” is a valid node name. That's probably why node is nil.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜