Hi Bill,

   Thanks for your response.

   This code works fine , but when i try to mount a single volume/account on
the same server , this code doesn't seem to work for mounting multiple
volumes/accounts.I'm always getting -43 error.If i unmount the earlier
volume/account on the same server then i'm able to mount another volume on
the same server.

    Can you please help me to solve this problem.

Thanks,
JanakiRam.
On Sat, Apr 19, 2008 at 1:18 AM, Bill Monk <[EMAIL PROTECTED]> wrote:

> On Apr 18, 2008, at 2:03 PM, Jens Alfke <[EMAIL PROTECTED]> wrote:
>
> I haven't used any of those functions. How about reading the
> > documentation? Just type "FSVolumeMount" into Xcode's documentation
> > viewer.
> >
>
> Well, um, that won't help him much, because there is no such function.
>
>
> Something like this will do the job:
>
>
> -(OSStatus)mountServer:(NSString *)serverAddress
>                        volumeName:(NSString *)volumeName
>                    usingTransport:(NSString *)transportName
>                        optionalMountDirectory:(NSString
> *)mountDirectoryPath
>                          username:(NSString *)userName
>                        passsword:(NSString *)password
>                  returnRefNum:(FSVolumeRefNum *)returnRefNum
> {
>
>
>    // encode afp:// URL for server, without userName/password
>    NSString *urlStringOfVolumeToMount = [NSString 
> stringWithFormat:@"%@://%@/%@",
> transportName, serverAddress, volumeName];
>
>   // make sure any space characters in the url string are percent-escaped
>    urlStringOfVolumeToMount = [urlStringOfVolumeToMount
> stringByAddingPercentEscapesUsingEncoding:NSMacOSRomanStringEncoding];
>
>   NSURL *urlOfVolumeToMount = [NSURL
> URLWithString:urlStringOfVolumeToMount];
>
>   // create NSURL for optional mount directory on server - left as an
> exercise for the reader
>
>        // To mount a volume quietly, without an authentication dialog,
> it's necessary that FSMountServerVolumeSync's
>        // userName and password params not be NULL.
>        // If they are encoded into the URL, and the server doesn't exist,
> passing NULL for these params
>        // causes the system to put up a "server is not available or may
> not be operational" dialog.
>        //
>        // The solution is to always pass userName and password directly to
> FSMountServerVolumeSync, and leave them
>        // out of the URL.
>        // This will mount the volume if it's possible, and if not, quietly
> return an error, and no authentication
>        // dialog will appear (assuming the name/password are valid, of
> course).
>        OSStatus error;
>        error = FSMountServerVolumeSync( (CFURLRef)urlOfVolumeToMount,
>                                NULL, //(CFURLRef)mountDirectoryPath, // if
> NULL, default location is mounted.
>                                (CFStringRef)userName,
>                                (CFStringRef)password,
>                                returnRefNum,
>                                 0L /* OptionBits, currently unused */ );
>
>        if ( error ) {
>                NSBeep();
>                NSLog( @"Server %@/%@ reported error %d", serverAddress,
> volumeName, error );
>        }
>
>
>        return error;
> }
>
>
> and used something like:
>
> FSVolumeRefNum refNum;
> OSStatus status;
>
> err = [self  mountServer:@"MyServer.local"
>              volumeName:@"volumeName"
>          usingTransport:@"afp"
>  optionalMountDirectory:@""
>                username:@"username"
>               passsword:@"password"
>            returnRefNum:&refNum];
>
> err = [self  mountServer:@"idisk.mac.com"
>              volumeName:@"youriDisk-Public"
>          usingTransport:@"http"
>  optionalMountDirectory:@""
>                 username:@"username"
>                passsword:@"" // assuming the iDisk has no password set on
> /Public
>             returnRefNum:&refNum];
>
>
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to