Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to add to IIS IpGrant collection from VFP, only get first entry... any clues

Status
Not open for further replies.

GriffMG

Programmer
Mar 4, 2002
6,333
FR
I'm trying to add an entry to an IIS security table called IpGrant.

I can GET a collection from the entry - it comes to VFP as an array -
but I don't seem to be able to pass the array back.

In the code below I have left out the step that would add an entry,
I'm just reading IPGrant, printing it out, then trying to put it back
and lastly reading it again

Code:
? "Getting IPSecurity List "
?
OBJSMTP= GETOBJECT("IIS://localhost/smtpsvc/1")
OBJIPSECURITY = OBJSMTP.GET("IPSecurity")
OBJCURRENTLIST = OBJIPSECURITY.IPGRANT
COUNT = 0
FOR EACH OBJIP IN OBJCURRENTLIST
	? OBJIP
	COUNT = COUNT + 1
NEXT
*objCurrentList.Add("1.1.1.1,255.255.255.255")
OBJIPSECURITY.IPGRANT = objCurrentList

OBJNEWLIST = OBJIPSECURITY.IPGRANT
COUNT = 0
FOR EACH OBJIP IN OBJNEWLIST
	? OBJIP
	COUNT = COUNT + 1
NEXT

objSMTP.Put("IPSecurity",objIpSecurity)
OBJSMTP.SETINFO

All I ever get in the OBJSECURITY.IPGRANT list is the first element of the array

I'm sure this is either really simple, or completely impossible - does anyone know?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
I haven't worked with this (and probably won't), but you say it comes to VFP as an array.

If you're going to pass an array back, it must be done by @reference. Otherwise, you'll always pass just the first element. (This applies to native Foxpro code. I'm not sold that's your issue here.)

Code:
objSMTP.Put("IPSecurity",@objIpSecurity)

Your naming convention, though, implies that you're actually throwing around an object. Likely a collection. Is that just a vestige of some code you copied from elsewhere?
 
A collection is more likely, indeed, as you used an Add method in a commented line. In some cases you may not loop a collection with a for each loop.
You might find a count=OBJIPSECURITY.IPGRANT.COUNT or count=OBJIPSECURITY.IPGRANT.LENGTH and can address the collection elements via OBJIPSECURITY.IPGRANT.item(n) with n from 0 to count-1 or 1 to count.

Have a breakpoint after the .GET("IPSecurity") and see what you get there. Inspect the variable at the commandline and see what intellisense tells you.

Bye, Olaf.

 
I did try using IPGRANT.ADD() but got an error saying it wasn't an object - I think.

I will see if I can try your suggestion with the breakpoint Olaf, the only trouble is the
machine is remote and doesn't have VFP on it.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Well breakpoints are out, no vfp at the far end and no STMP at this end...

this is the line that is causing the problem:
Code:
OBJIPSECURITY.IPGRANT = objCurrentList

I think the OBJIPSECURITY.IPGRANT is expecting a VB style array and I'm offering it
one from VFP - and it can only read the first element.

I am wondering if there is a way to make the VFP array look like the VB one, I'm going to try putting a chr(0)
on the end of the strings...

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Well,

in VFP, the only way to address an array as a whole and not the single first array element, is forwareding it by reference, eg DO func WITH array or func(@array), but you can't set some property, neither VFP nor COM property to an array. A VFP array property could be set or created by ACOPY, but I doubt this'll work in case of a COM property.

I also still thing the COM object property is not an array, but a collection.

Another thing: ZIP your HOME() folder, upload it remote and debug there, that's allowed by the EULA, as the VFP license is a per developer license and not a per computer/installation license. You just have to make sure you don't leave VFP there usable by someone else.

Bye, Olaf.
 
Olaf, I think you are quite correct and there is no simple way to get that array into that COM object, unless it supports something like this:

Code:
objSMTP.Put("IPSecurity.IpGrant",@objCurrentList)

Sometimes you need to admit defeat and code it in another language.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
If it's an array, the obvious thing to try would be adressing it's single elements.

IPSecurity.IpGrant[0] = "1.1.1.1"
IPSecurity.IpGrant[1] = "255.255.255.255"

Something like that.

Bye, Olaf.
 
I DID NOT think of that option, worth a crack, as long as I don't need to add an element.

Thank you

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
I get 'Does not support a collection' when I try and assign to the IpGrant using [x] notation


Very clever idea though.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Same for (x) notation - worth a try.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
I have found a solution, not to the problem I thought I had - don't think I can do that, but to my underlying
project.

I only need one IPGrant address at a time to be in place, I just need to change it programatically.
So, if all I can get into IPGrant is the one address that I want, I have no problem.

Thank you for your assistance

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Unfortnately that only works where the object has a method that takes the array as a parameter.
This is a simple assignment, so I only ever get the first element.

Thanks though Craig

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top