• 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: "stephen joseph butler" <email@hidden>
  • Date: Fri, 5 Jan 2007 01:23:02 -0600

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


  • Follow-Ups:
    • Re: Using DirectoryService to Find Users
      • From: King Chung Huang <email@hidden>
References: 
 >Using DirectoryService to Find Users (From: King Chung Huang <email@hidden>)

  • Prev by Date: Re: Observing bounds of an NSBezierPath
  • Next by Date: iTunes Database
  • Previous by thread: Using DirectoryService to Find Users
  • Next by thread: Re: Using DirectoryService to Find Users
  • Index(es):
    • Date
    • Thread