We are using Wildfly 10 for the first time, upgrading from JBoss EAP 5.1.2. One thing that we need is to have our datasources using the ojdbc6 Oracle driver. I know there are 3 ways to configure them:
1 - Installing the driver and configuring the modules and datasources via configuration files, as shown in this article:
http://www.adam-bien.com/roller/abien/entry/installing_oracle_jdbc_driver_on
2 - Put the ojdbc6.jar in the D:\wildfly-10.1.0.Final\standalone\deployments folder, start the server. Via Wildfly 10 Administration Console, configure the datasource in Configuration -> Subsystems -> Datasources -> Non-XA usint the ojdbc6 driver we put in deployments folder;
3 - Via Wildfly 10 Administration Console, deploy the ojdbc6.jar like any normal deploy in Deployment tab, and them via Wildfly 10 Administration Console, configure the datasource in Configuration -> Subsystems -> Datasources -> Non-XA usint the ojdbc6 driver we just deployed.
Since our customers are used and demand instalations via administration consoles whenever possible, we choose way number 3 to configure the ojdbc6 driver and create our datasources.
Now here's the problem: our application has an environment check that among other things checks the Oracle driver version to make sure we are using the ojdbc6 Oracle driver. This environment check is mandatory for our application to start. Or environment check class has the following code to check the Oracle driver:
/**
* #return Caminho do jar do driver Oracle
* #see "http://www.javaxt.com/Tutorials/Jar/How_to_Get_the_Physical_Path_of_a_Jar_File"
*/
private String getOracleJarPath() {
try {
// Oracle driver class
final Class<?> clazz = oracle.jdbc.OracleDriver.class;
final String path = clazz.getPackage().getName().replace(".", "/");
String url = clazz.getClassLoader().getResource(path).toString();
url = url.replace(" ", "%20"); // Normalize URI
url = url.replace(path + "/", ""); // remove package from path
final URI uri = new URI(url);
return new File(uri.getPath()).getAbsolutePath();
} catch (final Exception e) {
// Nothing to do
}
return StringUtils.EMPTY;
}
When I deploy our application via Wildfly 10 Administration Console an error happens at line 38 (8 in the above code):
2017-06-21 10:54:49,332 ERROR [br.com.synchro.framework.ambiente.service.impl.ValidadorAmbienteServiceImpl] (default task-2) Erro ao validar ambiente em todos os estágios.: java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
at br.com.synchro.sfw.infra.ambiente.integration.impl.ValidadorAmbienteVersaoDriverJdbc.getOracleJarPath(ValidadorAmbienteVersaoDriverJdbc.java:38)
at br.com.synchro.sfw.infra.ambiente.integration.impl.ValidadorAmbienteVersaoDriverJdbc.validarDriverOracle(ValidadorAmbienteVersaoDriverJdbc.java:149)
at br.com.synchro.sfw.infra.ambiente.integration.impl.ValidadorAmbienteVersaoDriverJdbc.validar(ValidadorAmbienteVersaoDriverJdbc.java:106)
at br.com.synchro.framework.ambiente.service.impl.ValidadorAmbienteServiceImpl.validarAmbienteSegundoEstagio(ValidadorAmbienteServiceImpl.java:137)
at br.com.synchro.framework.ambiente.service.impl.ValidadorAmbienteServiceImpl.validarAmbienteTodosEstagios(ValidadorAmbienteServiceImpl.java:156)
at br.com.synchro.framework.gui.presentation.filter.ValidacaoAmbienteFilter.doFilter(ValidacaoAmbienteFilter.java:55)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at br.com.synchro.framework.gui.presentation.filter.AplicacaoPatchFilter.doFilter(AplicacaoPatchFilter.java:53)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at br.com.synchro.framework.gui.presentation.filter.XUaCompatibleFilter.doFilter(XUaCompatibleFilter.java:28)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
...
Thus mean, we can't find the driver in our application classpath!
When I created the driver and datasource via method 1, our application works with no problem. But if I use method 2 or 3 the application cannot find the driver in the classpath at all. Since our customers demand instalation exclusively via Administration Console, what can I do or what am I doing wrong that the driver is not in our application classpath?!
Thanks in advance!!!
Try something like:
#Startup
#Singleton
public class JDBCDriverVerifier {
#Resource(name="java:jboss/datasources/YourDS)
private DataSource ds;
#PostConstruct
void checkDriver() {
try(Connection conn = ds.getConnection()) {
DatabaseMetaData metaData = conn.getMetaData();
String driverName = metaData.getDriverName();
String driverVersion = metaData.getDriverVersion();
// get other meta data if useful
// validate and throw exception if it fails...
}
}
}
You may need to experiment to see what metadata is the most useful for you.
Note that this will work even if you have a WAR only deployment.
Also, it's worth educating your customers about the value of using JBoss CLI scripts to configure their servers. These scripts can be source controlled (and commented), allowing new environments to be brought up quickly because they make the process repeatable. Console configuration is almost never repeatable. Most of the major Java EE server implementations have this capability in one form or another.
Related
I'm using milton, and my upload code as follows:
#PutChild
#Transactional
public FileContentItem uploadFile(FolderContentItem parent, String name, byte[] bytes){
String traceId = UuidGenUtil.createUuid();
try {
QUERY_LOGGER.info("[uploadFile][NetdiskController],action=Request, name={}, size={},traceId={}",name,bytes.length,traceId);
In windows, i can upload file successfully, but with Mac Finder, the length of bytes is always 0, and the error as follow:
The Finder can't complete the operation because some data in "Shot.png" can't be read or written (Error code -36)
Anyone know why? Thanks
Update: I try ForkLift webdav client in mac and can upload file successfully
The problem is that mac finder sends first request for creating new file without any byte
After it - call LOCK, which is not available for Dav Level 1, that's why you have bad response from server and mac stop uploading a file. This method availiable only for Dav level 2, so you have to get enterprise license of milton to make it work
After Locking object Finder uploads the file
After - calls UNLOCK method
SO if you want to use mac finder for webdav in milton you have several options:
Get the trial enterprise license and look into this example:https://github.com/miltonio/milton2/tree/master/examples/milton-anno-ref
Realize these methods by yourself by webdav specs
Mock it - extend from MiltonFilter or look into MyOwnServlet in example and in method doFilter/service write something like this:
//mock method, do not use it in production!
HttpServletRequest request = (HttpServletRequest)req;
HttpServletResponse response = (HttpServletResponse) resp;
if(request.getMethod().equals("LOCK")){
response.setStatus(200);
response.addHeader("Lock-Token", "<opaquelocktoken:e71d4fae-5dec-22d6-fea5-00a0c91e6be4>");
} else if(request.getMethod().equals("UNLOCK")){
response.setStatus(204);
}else {
doMiltonProcessing((HttpServletRequest) req, (HttpServletResponse) resp);
}
I've checked this code working in the examble by link above: make in web.xml method serving by MyOwnServlet, disable authentication in init by implementing empty security manager, set controller packages to scan "com.mycompany"
p.s. to build the example project I've to delete milton client dependency from pom.xml file
There is a plethora of frustratingly incorrect (better description - "close but no cigar") information concerning remote access to JBoss EJBs from a standalone application. I've been beating my head against this wall for over a day with no success.
I'm trying to port an EJB from WebLogic to JBoss, which is called by a standalone application running on another server.
I've been here, here, and several other places chasing down various "solutions" to my problem without success. I've tried reading the official documentation which wants me to install a "quickstart" based on Maven, which may or may not fit my situation, and which so far I have decided not to pursue. (My project is not built with Maven, it uses Gradle, but I am reasonably certain that I've managed to get all the right dependencies deployed).
I have a stateful EJB deployed in a WAR inside an EAR (previous implementation of deploying it simply in a WAR did not help matters).
I configure the client thusly:
public InitialContext createInitialContext() throws NamingException {
Properties prop = new Properties();
prop.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
prop.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jboss.naming.remote.client.InitialContextFactory");
prop.put(Context.PROVIDER_URL, purl);
prop.put(Context.SECURITY_PRINCIPAL, "myusername");
prop.put(Context.SECURITY_CREDENTIALS, "mypassword");
prop.put("jboss.naming.client.ejb.context", false);
return new InitialContext(prop);
}
public void closeContext(Context context) throws NamingException {
if (context != null) {
context.close();
}
}
private String getJndiName(
String prefix,
String appName,
String moduleName,
String distinctName,
String beanName,
Class viewClass,
boolean stateful)
{
StringBuilder builder = new StringBuilder();
if (prefix != null && prefix.length() > 0) {
builder.append(prefix).append(':');
}
builder.append(appName)
.append('/')
.append(moduleName)
.append('/')
.append(distinctName)
.append('/')
.append(beanName).append('!')
.append(viewClass.getName());
if (stateful) {
builder.append("?stateful");
}
return builder.toString();
}
public Object lookup(Context context) throws NamingException {
final String prefix = "ejb";
final String appName = "myearname";
final String moduleName = "mywarname";
final String distinctName = "";
final String beanName = "MyBean";
final Class viewClass = MyBeanInterface.class;
String jndi = getJndiName(prefix, appName, moduleName, distinctName, beanName, viewClass, true);
return context.lookup(jndi);
}
Note that no "distinct name" is provided as none is needed. "distinct name" is supposed to be optional:
All of this gets invoked by:
MyBeanInterface sstatus = null;
try {
ctx = createInitialContext();
sstatus = (MyBeanInterface) lookup(ctx);
} catch (Exception ex) {
...
}
When this code is invoked, the following error message is produced:
Caused by: java.lang.IllegalStateException: EJBCLIENT000024: No EJB receiver available for handling [appName:SockTransport, moduleName:SockTransport, distinctName:] combination
at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:873) ~[ttjd.jar:?]
at org.jboss.ejb.client.EJBClient.createSessionWithPossibleRetries(EJBClient.java:222) ~[ttjd.jar:?]
at org.jboss.ejb.client.EJBClient.createSession(EJBClient.java:202) ~[ttjd.jar:?]
at org.jboss.ejb.client.naming.ejb.EjbNamingContext.doCreateProxy(EjbNamingContext.java:227) ~[ttjd.jar:?]
at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createEjbProxy(EjbNamingContext.java:204) ~[ttjd.jar:?]
Using the above code, the JNDI name I am supplying is
ejb:myearname/mywarname//MyBean!com.whatever.my.package.MyBeanInterface. Note the double slash caused by the missing distinctName. I can and have rejiggered this code to produce instead ejb:myearname/mywarname/MyBean!com.whatever.my.package.MyBeanInterface and this makes no difference.
Frankly, I think this error message is a red herring. I suspect that there is some other problem with my setup that is not being caught and breaking on this interface. I don't think the distinct name or lack thereof has anything to do with the problem. I think that's simply how they log the object that can't be looked up.
Before I go down the path of figuring out how to add a useless "distinct name" in a probably vain attempt to keep JBOSS happy, can someone venture a guess as to what the real problem may be?
UPDATE:
The suggestions of #Steve_C are quite illuminating but I still have not gotten them to work. He left a few points out of the initial context creation:
Context.URL_PKG_PREFIXES
Context.INITIAL_CONTEXT_FACTORY
"jboss.naming.client.ejb.context"
but these were mentioned in the resource he cited - very handy by the way.
So I added these and my createInitialContext method now looks like this:
public InitialContext createInitialContext() throws NamingException {
Properties prop = new Properties();
prop.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
prop.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jboss.naming.remote.client.InitialContextFactory");
prop.put(Context.PROVIDER_URL, "http-remoting://{server-ip}:{server-port});
prop.put("jboss.naming.client.ejb.context", true);
return new InitialContext(prop);
}
Why PROVIDER_URL is necessary when I've already supplied server-ip and server-port in the jboss-ejb-client.properties file remains mysterious, but it makes a difference.
With these three items added to my initial context environment, now I get a different error message (EJBCLIENT000025 instead of EJBCLIENT000024):
java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:SockTransport, moduleName:SockTransport, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext#67f639d3
at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:798) ~[ttjd.jar:?]
at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:128) ~[ttjd.jar:?]
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:186) ~[ttjd.jar:?]
at org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:255) ~[ttjd.jar:?]
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:200) ~[ttjd.jar:?]
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:183) ~[ttjd.jar:?]
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:146) ~[ttjd.jar:?]
at com.sun.proxy.$Proxy20.create(Unknown Source) ~[?:?]
I suppose this counts as progress, but I'm finding this more difficult than it needs to be. I wonder if these new properties need to be in the properties file, but the official documentation pretty clearly says they don't.
The most flexible WildFly/JBossEAP remote EJB lookup and invocation can be done as follows:
Create a jboss-ejb-client.properties file which must be on the client classpath:
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=<ip of jboss eap host>
remote.connection.default.port = 8080
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
The EJBCLIENT000024: No EJB receiver available for handling error message is a symptom of a missing jboss-ejb-client.properties file.
Create an InitialContext:
Properties jndiProps = new Properties();
jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
Context ctx = new InitialContext(jndiProps);
Note that no other properties are required.
Lookup the bean and call it:
ServiceLogic beanRemoteInterface = (ServiceLogic) ctx.lookup("ejb:/WhizBangSessionEJB/WhizBangSessionEJB!com.whatever.hostinterface.ServiceLogic?stateful");
String bar = beanRemoteInterface.sayHello();
System.out.println("Remote Foo bean returned " + bar);
Note the ?stateful on the end of the JNDI name that is required for stateful EJBs.
Output:
Jan 11, 2017 11:07:46 PM org.jboss.ejb.client.EJBClient <clinit>
INFO: JBoss EJB Client version 2.1.4.Final
Jan 11, 2017 11:07:46 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.4.0.Final
Jan 11, 2017 11:07:46 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.4.0.Final
Jan 11, 2017 11:07:46 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 4.0.21.Final
Jan 11, 2017 11:07:46 PM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: EJBCLIENT000017: Received server version 2 and marshalling strategies [river]
Jan 11, 2017 11:07:46 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext#29ca901e, receiver=Remoting connection EJB receiver [connection=org.jboss.ejb.client.remoting.ConnectionPool$PooledConnection#5649fd9b,channel=jboss.ejb,nodename=steves-mbp]} on channel Channel ID ecac0ca6 (outbound) of Remoting connection 6536e911 to /192.168.12.6:8080 of endpoint "config-based-ejb-client-endpoint" <520a3426>
Remote Foo bean returned hello
More information can be found in Remote EJB invocations via JNDI - EJB client API or remote-naming project.
More sample code can be found in the QuickStart repo at wildfly/quickstart/ejb-remote
PS. If you really want to set the distinct-name then you need to add a jboss-ejb3.xml file to your EJB jar containing:
<jboss:ejb-jar xmlns:jboss="http://www.jboss.com/xml/ns/javaee"
xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-ejb3-2_0.xsd"
version="3.1"
impl-version="2.0">
<distinct-name>something-distinct</distinct-name>
</jboss:ejb-jar>
Dynamic EJB Client Properties
If you need to be able to provision the jboss-ejb-client.properties
dynamically then the simplest solution would be generate this file
on the fly, possibly at client initialisation time.
Set the jboss.ejb.client.properties.file.path system property to
point at a secure writable file system location. An insecure example might be something like
-Djboss.ejb.client.properties.file.path=/tmp/whizbang-ejb.properties
or
System.setProperty("jboss.ejb.client.properties.file.path", "/tmp/whizbang-ejb.properties");
Generate a properties file named
with the String defined by jboss.ejb.client.properties.file.path according to the format described for jboss-ejb-client.properties files.
Proceed with InitialContext creation
There are other alternatives that involve hacking the provided jboss-ejb-client
code. However you need to remember that this is LGPL code and you and your company
would need to make your hacks publicly available.
Before sharing what I learned I want to give a big shout-out to #Steve_C who went way beyond the call of duty in helping me, including a lengthy chat session. In case anyone wonders, he is not ME, by the way.
Meaning no disrespect to #Steve_C or his answer (which I have upvoted as useful), there is more to be said here, as I've learned from very painful experience.
Here are some things I have learned:
1) It is necessary to have a jboss-ejb-client.properties file.
2) This file can be located either on the classpath or specified in a location specified by the following System property, which I set just prior to invoking the InitialContext constructor:
System.setProperty("jboss.ejb.client.properties.file.path", "/path/to/properties/file");
return new InitialContext(prop);
3) This file must name the connections:
remote.connections=conn1,conn2
4) For each connection named in the above property, host and port entries must be stored in the properties file
remote.connection.conn1.host=10.0.0.1
remote.connection.conn1.port=8080
remote.connection.conn2.host=10.0.0.2
remote.connection.conn2.port=8080
5) For each connection named, there must also be some method of authentication specified, either
a)
remote.connection.conn1.username=user1
remote.connection.conn1.password=topSecret
remote.connection.conn2.username=user2
remote.connection.conn2.password=open_sesame
or b)
remote.connection.conn1.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.conn2.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
which literally indicates that anonymous no-password invocations are not disallowed. (Let's hear it for double negatives!) I suppose it would be theoretically possible to have one connection using a password and another allowing anonymous login but I can't imagine why. However this is done, it must be specified connection by connection. There is an incorrect example on the web that includes both
remote.connection.conn2.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
and username/password properties for the connection. The net effect of this is that the credentials can be incorrect and you still get login. I tried this and found it to be the case.
6) In spite of appearances, the specifying of java.naming.provider.url is necessary. It would be nice if JBoss could figure this out from the connection host and port properties mentioned above, but it can't! There may or may not be a good reason for this, I simply do not know.
Annoyingly, this CANNOT be specified in the Properties file. This seems to be a bug in the JBoss client. Since ":" is equivalent to "=" in the Java properties file specification, it is impossible to store URLs there with the http-remote:// notation or any url with the colon slash slash. The colon must be escaped with a backslash but evidently the JBoss client code is not calling Properties.load() to resolve the escaping correctly, but rather attempting to read it line for line? So this one must be specified in the Properties passed to the InitialContext creation. I have tried both ways and found that specify it in code works, whereas specifying it in a properties file doesn't.
So we have the unfortunate situation that there are two methods of supplying data to the InitialContext, some by properties file and some in the initial environment Hashtable passed to the InitialContext constructor. Some things must be done in one place, and other things must be done in the other. And none of this is properly documented.
ASP.NET site hosted on Azure VM. ApplicationInsights Status Monitor installed on VM. Default ApplicationInsights.config created by "Add AppInsights" menu in Visual Studio, only custom initializer added instead of ikey:
<Add Type="WebSite.WebSiteTelemetryInitializer, WebSite" />
Code:
public class WebSiteTelemetryInitializer : ITelemetryInitializer
{
public void Initialize(ITelemetry telemetry)
{
TelemetryConfiguration.Active.InstrumentationKey = WebConfigurationManager.AppSettings["ikey"];
telemetry.Context.User.Id = Environment.UserName;
telemetry.Context.Session.Id = Guid.NewGuid().ToString();
telemetry.Context.Component.Version = typeof(WebSiteTelemetryInitializer).Assembly.GetName().Version.ToString();
}
}
All works as expected, but there is no performance data (Cpu, memory). After adding apppool user to Performance Monitor Users group:
$group = [ADSI]"WinNT://$Env:ComputerName/Performance Monitor Users,group"
$ntAccount = New-Object System.Security.Principal.NTAccount("IIS APPPOOL\DefaultAppPool")
$strSID = $ntAccount.Translate([System.Security.Principal.SecurityIdentifier])
$user = [ADSI]"WinNT://$strSID"
$group.Add($user.Path)
there is no data for dependency calls.
UPDATE
There are 3 repeating trace logs:
AI (Internal): Complete creating shadow copy of extension,
extensionBaseDirectory: C:\inetpub\wwwroot\site\bin, extensionName:
Microsoft.ApplicationInsights.Extensions.Intercept with error System.UnauthorizedAccessException: Access to the path 'C:\Windows\system32\config\systemprofile' is denied.
AI (Internal): Extension attach failure, unable to attach, baseFolder: C:\inetpub\wwwroot\site\bin, nativeExtensionName: Microsoft.ApplicationInsights.Extensions.Intercept
AI (Internal): [msg=RemoteDependencyModule failed];[msg=System.InvalidOperationException: Failed to attach extension, hresult: 2147500037
Remote dependencies:
Ok, so that is what is preventing ApplicationInsights from collecting dependencies:
AI (Internal): Complete creating shadow copy of extension, extensionBaseDirectory: C:\inetpub\wwwroot\site\bin, extensionName: Microsoft.ApplicationInsights.Extensions.Intercept with error System.UnauthorizedAccessException: Access to the path 'C:\Windows\system32\config\systemprofile' is denied.
C:\Windows\system32\config\systemprofile is what is set as a temp folder for your process. You need to change temp folder for the process and make sure that your application can write there. (ApplicationInsights is coping native binaries there that are used by profiler. Temp folder is also used when you have temporary internet access issues. It saves events that were not sent and sends them when connection is restored.)
Performance counters:
In order to collect performance counters the user that application pool runs under (usually it's ApplicationPoolIdentity) should be a member of Performance Monitor Users group on the box. Ensure that it's added there and you should do iisreset after adding the user to the group otherwise changes will not take effect.
Described here at the bottom:
http://blogs.msdn.com/b/visualstudioalm/archive/2014/12/11/updated-application-insights-status-monitor-to-support-12-and-later-application-insights-sdk.aspx
Just to add, you can change the temp folder that Application Insights writes to by editing the end of applicationsinsights.config file and adding the location of temp folder. Here's what I've done:
<TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel">
<StorageFolder>D:\AITempFolder</StorageFolder>
Hope this helps someone else too.
I am working on a small project, in asp.net mvc3, that would copy the deployment files from a local drive to a share drive on a window server 2008 R2 server. I am connected using WMI, and the connection is successful. However, I tried to create a folder, and I receive the message "Logon failure: unknown user name or bad password." Here is a sample code:
bool isConnected = false;
options.Username = user.Name.Trim();
options.Password = user.password.Trim();
mScope = new ManagementScope("\\\\xxx.xxx.xxx.xxx\\root\\cimv2", options);
mScope.Connect();
if (mScope.IsConnected == true)
{
//I've gotten to this point. Then, the code below throw the exception
Directory.CreateDirectory(#"\\\\xxx.xxx.xxx.xxx\Tester\shareFile.txt");
isConnected = true;
}
I'd like to know what am I doing? Is that the right way of doing it?
it is the correct way however it will be the current user you are trying to access that gets passed to the remote computer to create the directory. The management scope at this point has nothing to do with Directory.CreateDirectory. These are 2 different "worlds". you do give the creds to ManagementScope but this has no affect on Directory.CreateDirectory. you could use impersonation to do what you are wanting to:
How do you do Impersonation in .NET?
it is unclear though if you are doing this in ASP.NET/MVC or a different platform. your tags indicate ASP.NET MVC but not your main question.
remember, if you are using ASP.NET/MVC, the credentials of the app pool are being used to perform such actions.
In our company, we have a project which should use Novell eDirectory with .net applications.
I have tried Novell Api (http://www.novell.com/coolsolutions/feature/11204.html) to connect between .NET applications. It is working fine.
But, as per requirement, we specifically need .net API to connect not with Novell Api, which is not working. Connection and binding with .NET Api DirectoryServices not working.
Our Novell eDirectory is installed with following credentials:
IP address: 10.0.x.xx(witsxxx.companyname.com)
Tree : SXXXX
New Tree Context: WIxxxK01-NDS.OU=STATE.O=ORG
ADMIN Context is: ou=STATE,o=ORG
admin : admin
password: admin
I used Novell Api and used following code
String ldapHost ="10.0.x.xx";
String loginDN = "cn=admin,cn=WIxxxK01-NDS,OU=STATE,o=ORG";
String password = string.Empty;
String searchBase = "o=ORG";
String searchFilter = "(objectclass=*)";
Novell.Directory.Ldap.LdapConnection lc = new Novell.Directory.Ldap.LdapConnection();
try
{
// connect to the server
lc.Connect(ldapHost, LdapPort);
// bind to the server
lc.Bind(LdapVersion, loginDN, password);
}
This is binding correctly and searching can be done.
Now my issue is with when I trying to use .NET APi and to use System.DirectoryServices
or System.DirectoryServices.Protocols, it is not connecting or binding.
I can't even test the following DirectoryEntry.Exists method. It is going to exception.
string myADSPath = "LDAP://10.0.x.xx:636/OU=STATE,O=ORG";
// Determine whether the given path is correct for the DirectoryEntry.
if (DirectoryEntry.Exists(myADSPath))
{
Console.WriteLine("The path {0} is valid",myADSPath);
}
else
{
Console.WriteLine("The path {0} is invalid",myADSPath);
}
It is saying Server is not operational or Local error occurred etc. I don't know what is happening with directory path.
I tried
DirectoryEntry de = new DirectoryEntry("LDAP://10.0.x.xx:636/O=ORG,DC=witsxxx,DC=companyname,DC=com", "cn=admin,cn=WIxxxK01-NDS,o=ORG", "admin");
DirectorySearcher ds = new DirectorySearcher(de, "&(objectClass=user)");
var test = ds.FindAll();
All are going to exceptions.
Could you please help me to solve this? How should be the userDN for DirectoryEntry?
I used System.DirectoryServices.Protocols.LdapConnection too with LdapDirectoryIdentifier and System.Net.NetworkCredential but no result. Only same exceptions.
I appreciate your valuable time and help.
Thanks,
Binu
To diagnose your LDAP connection error, get access to the eDirectory server from the admins, and use iMonitor (serverIP:8028/nds and select Dstrace), in Dstrace clear all tabs and enable LDAP tracing, then do your bind see what happens on the LDAP side to see if there is a more descriptive error there. Or if you even get far enough to bind and make a connection.