The static method of GetCurrentDomain() works without issue but, when I try to use another method such as FindDomainController(), I receive a MethodNotFound exception error.
Use Domain.FindDomainController method to find all DC in the domain:
[System.DirectoryServices.ActiveDirectory.Domain]::GetComputerDomain().DomainControllers
[System.DirectoryServices.ActiveDirectory.Domain] doesn't have a FindDomainController() method.
or use Domain.FindDomainController Method
[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().FindDomainController()
This one finds any domain controller in the domain. There is no guarantee that the same domain controller will be found by another call to this method.
Related
How to call a method in Camel Route using Java DSL? I want to get a compile time error in Eclipse if I am using the wrong signature for method.
.bean(Foo.class, "setDetails("1", "Camel")")
Here I won't get compile time error for the wrong method signature as method was defined in string.
This is, as far as I know, not possible because Camel calls the method through reflection API.
What you can do, is to create constants in Foo.class with the method names and then use the constants in the bean calls instead of the hard-coded method name Strings.
But even then, you are of course able to rename a method in the bean without adapting the constant. The functionality would be broken but the compiler would be still happy.
If the bean is dedicated to Camel routes and under your control, the best you can do is to refactor the bean.
Remove the method parameters, set them on the message exchange and inject them with #Header, #Property
Split the bean into very small beans with only one method to get rid of the method names
Try this
.bean(Foo.class, "setDetails(1, 'Camel')")
If your first parameter is of type int just put the number without quotes
Second parameter is String, so you should put String to single quotes.
According to the docs, from camel 2.9 onwards, you can do pass in an integer and a string as parameters in a method call (using your example) like this:
.bean(Foo.class, "setDetails(1, 'camel')")
OR
.to("bean:Foo?method=setDetails(1, 'camel')")
If I understand the question correctly, you want a compile-time error about something that is evaluated at runtime. This is simply not possible.
I have a requirement to specify a method name at run time to intercept using a common interceptor.Is there any way to add a new pointcut at runtime
You can solve problem in this way.
1) Always intercept same method
Example: Before Advice : public void preProcess() {}
2) Use method argument for calling target method at Runtime from AOP intercepted method #preProcess
Is it possible to access the current request in Kohana's bootstrap? I tried accessing Request::$current but $current doesn't seem to be defined at that stage. Is there any way around that? Also at what point in the application is Request::$current defined?
It's not possible, because Request object is created in index.php after including bootstrap.php:
// Bootstrap the application
require APPPATH.'bootstrap'.EXT;
/**
* Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
* If no source is specified, the URI will be automatically detected.
*/
$request = Request::factory();
If you must access it, do it in the index.php after it has been created, although maybe you could tell us what exactly are you trying to do?
You can use it after Kohana initialization.
Kohana::init(...);
Also, good practice is using interface methods instead of public variable. I'm wondering why the developers keep $current as a public field.
So.. use
Request::current();
Also, It seems that using
Request::initial();
is better idea. But it depends on your realization.
I have an admin controller that I would like to utilize functions in other controllers (these functions do not represent pages that someone would load in their browser), but it cannot utilize those functions because the functions in the other controllers are private. They are private because I don't want the public to access them. Is there a way to make a controller function not accesible to the public without making the function private or protected?
public function __blah(){
// function that can't be accessed from outside, but can be called from other functions
}
Based on what I've read in the comment of the answer Piotr gave you:
You don't use an admin controller. You want to use admin prefixes:
http://book.cakephp.org/view/950/Prefix-Routing
And authentication:
http://book.cakephp.org/view/1250/Authentication
If you call - and thats how your comment sounds like - one controller from another you're doing something totally wrong in an MVC framework. If it should be re-usable code it should go into components if it's about admin action use the prefix routing and admin_* methods, auth component and protected methods for what you call "helper" methods.
Yes.
You have a lot of information in the CakePHP Book about ACL (access control list) and that is exactly what you're looking for.
Or you may use Auth component.
I see three possible solutions (they can also be combined):
The first solution is to move the code you want to reuse to components (as mentioned by burzum).
The second solution depends on your code. It's possible that you do stuff in the controller which should be done in the model. In this case, move the respective code to the model.
The third solution is to put the code you want to reuse into plain old PHP classes and load them as vendor files.
When I'm making web service calls from Silverlight using a service reference, is there any way to have the (generated) SoapClient objects modify the address that they call the service on?
Specifically, I'd like to tack on a QueryString value onto each call that the service makes. So if I have
DataService.SilverlightServiceSoapClient C = new DataService.SilverlightServiceSoapClient();
Is there any way to do something like:
C.Address += "?Foo=Bar";
Which would allow me to, from my WebMethod, say:
HttpContext.Current.Request.QueryString["foo"];
Obviously I can modify my WebMethods to take this value in as a parameter, but I'd like to avoid doing that if possible.
Since you are already using service references, you can simply use the overload of the proxy class constructor that accepts an EndpointAddress as a parameter. Alternatively, you can create multiple endpoint configuration and have the code simply use the chosen configuration - which may include URL changes.
See Understanding Generated Client Code on MSDN.
It looks like the best way to do this is to just use one of the overloaded constructors and supply the uri yourself
C = new DataService.SilverlightServiceSoapClient(new BasicHttpBinding(), new System.ServiceModel.EndpointAddress("http://blah/blah/blah/SilverlightService.asmx?Foo=Bar"));