• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Using DirectoryService to Find Users
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using DirectoryService to Find Users


  • Subject: Re: Using DirectoryService to Find Users
  • From: King Chung Huang <email@hidden>
  • Date: Fri, 05 Jan 2007 22:05:27 -0700

Ah, the hazards of copying sample code without fully reading through it! I reset numResults to 0, and that part works as expected. It's too bad the comparison is by string value and not integer value. I guess I'll just have to fetch all the users and filter out afterwards.

Thanks,

King Chung Huang

On 5-Jan-07, at 12:23 AM, stephen joseph butler wrote:

2007/1/5, King Chung Huang <email@hidden>:
(I'm not sure if this is the best list to post this question on. If
there's a more appropriate list, please let me know!)

I'm trying to use DirectoryService to get a list of users with uid >
500 (ie: "normal" users). Using Technical Q&A 1462 as a starting
point, I modified its search parameters to find kDS1AttrUniqueID
that's eDSGreaterThan "500". But, it only returns one result, and
it's the Unknown User with uid 99. Does anyone know what's wrong with
my code? Here's a snippet of it, and a link to the full code.

Welcome to Open Directory, my hell for the past two weeks.

patternToMatch = dsDataNodeAllocateString(dirRef, "500");
matchType = dsDataNodeAllocateString(dirRef, kDS1AttrUniqueID);
requestedAttributes = dsBuildListFromStrings(dirRef,
kDS1AttrDistinguishedName, kDS1AttrUniqueID, NULL);
status = dsDoAttributeValueSearchWithData(nodeRef, dataBuff,
&recordTypesToSearchFor, matchType, eDSGreaterThan, patternToMatch,
requestedAttributes, FALSE, &numResults, &context);

http://apollo.ucalgary.ca/~king/DSSearchPractice.zip

Your error isn't in the truncated code, so thanks for providing the whole example.

The problem is that you forgot to set numResults to 0 before calling
dsDoAttributeValueSearchWithData. It contained a previous result of 1
from dsFindDirNodes, so was only returning the first result (the
Unknown User).

However, I don't believe this code will ultimately do what you want.
NetInfo doesn't seem to have a concept that some datatypes should be
compared as integers. It appears to be returning all values with a
strcmp( attribute, "500" ) > 0.

I think this could would probably work on an LDAP node, however.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Using DirectoryService to Find Users (From: King Chung Huang <email@hidden>)
 >Re: Using DirectoryService to Find Users (From: "stephen joseph butler" <email@hidden>)

  • Prev by Date: Re: How do I subclass the NSScrollView of PDFView?
  • Next by Date: Getting File Info
  • Previous by thread: Re: Using DirectoryService to Find Users
  • Next by thread: iTunes Database
  • Index(es):
    • Date
    • Thread