accessing netinfo db from cocoa?

  • Hi,

    I am trying to find a way to access the netinfo DB from cocoa.
    Specifically the sharing (AFP, SMB, etc).
    know that server has the command line util 'sharing' for just this
    purpose.
    unfortunately this command is not available in the Client version of
    os x :(

    the reason i need this is because my app has a client side (on one
    mac) which passes a reference (the name) of a shared resource back to
    the server side (on another mac) where the shared resource is based/
    shared from.
    The server then sends update messages to the client that something has
    changed on the resource.

    so the server side needs to find out what (if any) shared resources
    are available and their alias's and full paths.

    Pointers or ideas are much appreciated.

    Kieren

    Olearia - Talking Books on the Mac
    http://olearia.googlecode.com/
  • On Aug 31, 2008, at 1:57 AM, Kieren Eaton wrote:

    > Hi,
    >
    > I am trying to find a way to access the netinfo DB from cocoa.
    > Specifically the sharing (AFP, SMB, etc).
    > know that server has the command line util 'sharing' for just this
    > purpose.
    > unfortunately this command is not available in the Client version of
    > os x :(
    >
    > the reason i need this is because my app has a client side (on one
    > mac) which passes a reference (the name) of a shared resource back
    > to the server side (on another mac) where the shared resource is
    > based/shared from.
    > The server then sends update messages to the client that something
    > has changed on the resource.
    >
    > so the server side needs to find out what (if any) shared resources
    > are available and their alias's and full paths.
    >
    > Pointers or ideas are much appreciated.
    >
    > Kieren
    >

    Hi!  I unfortunately believe that what you are doing will be
    impossible, at least if you're using Leopard.  To my knowledge, the
    NetInfo database system has been completely deprecated and removed
    from Mac OS X as of Leopard, in favor of other services.  I'm not sure
    what the alternative solution for your case would be, however. :(

    Best,
    Andrew
  • On Aug 31, 2008, at 4:57 AM, Kieren Eaton wrote:

    > Hi,
    >
    > I am trying to find a way to access the netinfo DB from cocoa.
    > Specifically the sharing (AFP, SMB, etc).
    > Pointers or ideas are much appreciated.

    Hello,

    Quick question: Are you using Leopard or Tiger machines? On Tiger, you
    can run the commands "niultil" or "nicl" to query the NetInfo database
    from your application. Note that in Leopard, Netinfo has been
    completely deprecated in favor of a local LDAP database. So, if you
    are using Leopard, run the command "dscl" from your application. In
    either case, you'll have to parse the command results in your app.

    On Tiger, the path you want to query is...

    /config/SharePoints/

    On Leopard, the path you want to query is...

      /Local/Default/SharePoints

    hope that helps,

    Jaime Magiera

    Sensory Research
    http://www.sensoryresearch.net
  • On Sun, Aug 31, 2008 at 8:57 PM, Kieren Eaton <kierene...> wrote:
    > I am trying to find a way to access the netinfo DB from cocoa.  Specifically
    > the sharing (AFP, SMB, etc).
    > know that server has the command line util 'sharing' for just this purpose.
    > unfortunately this command is not available in the Client version of os x :(
    >

    You'll probably be able to get the information you want out of the
    DirectoryService framework:
    <http://developer.apple.com/documentation/Networking/Conceptual/Open_Directo
    ry/
    >

    Phil
  • If you want to do it fast, without shell output parsing, and in a way
    that will work on 10.4 *and* 10.5, use the Directory Services C API.
    The downside is that it's more complex than many of the Cocoa APIs
    you're likely used to.

    Docs:

    <http://developer.apple.com/documentation/Networking/Conceptual/Open_Directo
    ry/Introduction/chapter_1_section_1.html
    >

    <http://developer.apple.com/documentation/Networking/Reference/Open_Director
    y_Ref/Reference/reference.html
    >

    Lots of source to learn from (the dscl sources are a good place to
    look for examples):

    http://www.opensource.apple.com/darwinsource/Current/DSTools-112/

    --
    m-s

    On 31 Aug, 2008, at 10:43, Jaime Magiera wrote:

    >
    > On Aug 31, 2008, at 4:57 AM, Kieren Eaton wrote:
    >
    >> Hi,
    >>
    >> I am trying to find a way to access the netinfo DB from cocoa.
    >> Specifically the sharing (AFP, SMB, etc).
    >> Pointers or ideas are much appreciated.
    >
    >
    > Hello,
    >
    > Quick question: Are you using Leopard or Tiger machines? On Tiger,
    > you can run the commands "niultil" or "nicl" to query the NetInfo
    > database from your application. Note that in Leopard, Netinfo has
    > been completely deprecated in favor of a local LDAP database. So, if
    > you are using Leopard, run the command "dscl" from your application.
    > In either case, you'll have to parse the command results in your app.
    >
    > On Tiger, the path you want to query is...
    >
    > /config/SharePoints/
    >
    > On Leopard, the path you want to query is...
    >
    > /Local/Default/SharePoints
    >
    > hope that helps,
    >
    > Jaime Magiera
    >
    > Sensory Research
    > http://www.sensoryresearch.net
  • >
    > If you want to do it fast, without shell output parsing, and in a way
    > that will work on 10.4 *and* 10.5, use the Directory Services C API.
    > The downside is that it's more complex than many of the Cocoa APIs
    > you're likely used to.
    >
    > Docs:
    >
    > <http://developer.apple.com/documentation/Networking/Conceptual/Open_Directo
    ry/Introduction/chapter_1_section_1.html
    >>
    >>
    >
    > Lots of source to learn from (the dscl sources are a good place to
    > look for examples):
    >
    > http://www.opensource.apple.com/darwinsource/Current/DSTools-112/
    >

    Thanks Michael and Phil
    That seems to be the way to go. Looks like its not going to be as easy
    as I thought.
    The source should make an interesting read.

    > On 31 Aug, 2008, at 10:43, Jaime Magiera wrote:
    >
    >>
    >> On Aug 31, 2008, at 4:57 AM, Kieren Eaton wrote:
    >>
    >>> Hi,
    >>>
    >>> I am trying to find a way to access the netinfo DB from cocoa.
    >>> Specifically the sharing (AFP, SMB, etc).
    >>> Pointers or ideas are much appreciated.
    >>
    >>
    >> Hello,
    >>
    >> Quick question: Are you using Leopard or Tiger machines? On Tiger,
    >> you can run the commands "niultil" or "nicl" to query the NetInfo
    >> database from your application. Note that in Leopard, Netinfo has
    >> been completely deprecated in favor of a local LDAP database. So, if
    >> you are using Leopard, run the command "dscl" from your application.
    >> In either case, you'll have to parse the command results in your app.
    >>
    >> On Tiger, the path you want to query is...
    >>
    >> /config/SharePoints/
    >>
    >> On Leopard, the path you want to query is...
    >>
    >> /Local/Default/SharePoints
    >>
    >> hope that helps,
    >>
    >> Jaime Magiera
    >>

    Thanks Jaime.  Currently I am Targeting 10.4 (my old G4 450Mhz wont
    run Leopard :(

    but I will also be writing a separate App for Leopard once I have all
    the base data extraction understood.
    So it looks like the Directory Services API is the way to go.

    Kieren