List all the lotus notes database - java

I tried to create a lotus notes client using Java. Now, I have a problem to list all the user defined databases. What I tried to do is
// testing purpose
private void printAllDb() throws NotesException
{
DbDirectory dir = session.getDbDirectory(host);
String server = dir.getName();
if(server.equals(""))
{
server = "Local";
}
System.out.println("database direcory list on server (" + server + ")");
Database db = dir.getFirstDatabase(DbDirectory.DATABASE);
do
{
System.out.println("file name: " + db.getFileName().toUpperCase() + " - " + db.getTitle());
} while((db = dir.getNextDatabase()) != null);
}
However, the program will throw the exception:
Exception in thread "main" NotesException: Server access denied
at lotus.domino.NotesExceptionHelper.read(Unknown Source)
at lotus.domino.NotesExceptionHolder._read(Unknown Source)
at lotus.priv.CORBA.iiop.RepImpl.invoke(Unknown Source)
at lotus.priv.CORBA.portable.ObjectImpl._invoke(Unknown Source)
at lotus.domino.corba._IDbDirectoryStub.getFirstDatabase(Unknown Source)
at lotus.domino.cso.DbDirectory.getFirstDatabase(Unknown Source)
at nz.co.sylresearch.sylsearch.agents.lotusnotes.LotusNotesAPIHandler.printAllDb(LotusNotesAPIHandler.java:58)
at nz.co.sylresearch.sylsearch.agents.lotusnotes.LotusNotesAPIHandler.main(LotusNotesAPIHandler.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

The issue is pretty clear. You are getting an access denied error to the server. The tricky part now is figuring out why.
You should start with making sure the username and password used to create the session object is correct. Then make sure that user has access to the server and has access to run Java code on the server. You'll have to check the server document in the Directory for that.

Related

W3CHttpResponseCodec error while Selenium Driver runs over VPN in Java

when I run my code without VPN my code works but when I connect VPN connection I get many errors such as:
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:277)
at RequestWithSelenium.checkBody(RequestWithSelenium.java:71)
at Main$3.run(Main.java:70)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)
My code explanation is simply that it tries to fetch sites which has includes error messages in body tag.
public void checkBody() {
for(String siteFinder: webSites) {
System.out.println("Selenium has visited " + siteFinder + " succesfully.");
driver.get(siteFinder);
bodyCheck = driver.findElement(By.tagName("body")).getText();
for(String errFinder: errorMsgs) {
if(bodyCheck.contains(errFinder)) {
errorSites.add(siteFinder);
}
}
}
driver.close();
if(errorSites.isEmpty()) {
System.out.println("There is no down site has found.");
} else {
System.out.println("Down site(s) list has shown below.");
int listMeter = 1;
for(String downSites: errorSites) {
System.out.println(listMeter + "th site: " + downSites);
listMeter++;
}
}
}
How can I fix this issue? Thanks.

Error in creating remedy ticket using java

i need a Java class to submit tickets to BMC Remedy's but i was getting error could anyone please help me how to resolve that error.
Find the below code:
public class RemedyCreateTicket {
public static void main(String args[]) {
ARServerUser arsServer = new ARServerUser();
Entry args1 = new Entry();
Entry incidentID;
String arForm = "HPD:IncidentInterface_Create";
String arForm1 = "HPD:IncidentInterface";
String IntEntryID = "";
String inciID = "";
try {
//Create Ticket Part
String strLastName = "radadiya";
String strFirstName ="pragnesh";
args1.put(new Integer("1000000076"),new Value("CREATE")); //ticket_action
args1.put(new Integer("1000000018"),new Value(strLastName)); //contact user first_name
args1.put(new Integer("1000000019"),new Value(strFirstName)); //contact user last_name
args1.put(new Integer("7"), new Value("1")); //ticket status
args1.put(new Integer("1000000099"),new Value("3")); //service type
//args1.put(new Integer("1000000163"),new Value("4000")); //impact
args1.put(new Integer("1000000162"),new Value("4000")); //urgency
args1.put(new Integer("1000000000"),new Value("Remedy 7.5 java api test")); //description
args1.put(new Integer("1000000215"),new Value("10000"));
arsServer.setServer("localhost");
arsServer.setUser("pragnesh");
arsServer.setPassword("password");
arsServer.setPort(3389);
arsServer.login();
//arsServer.setPort(3389);
IntEntryID = arsServer.createEntry(arForm, args1);
System.out.println("intEntryID="+IntEntryID);
int[] entryField = {1000000161};
incidentID = arsServer.getEntry(arForm,IntEntryID,entryField);
if(incidentID!=null){
System.out.println(incidentID);
}
System.out.println("------------");
for (Object o : incidentID.entrySet()) {
Map.Entry e = (Map.Entry) o;
System.out.println(e.getKey() + " => " + e.getValue().getClass() + " " + e.getValue());
if(e.getKey().toString().equalsIgnoreCase("1000000161")){
inciID=e.getValue().toString();
}
}
System.out.println("IncidentID = " + inciID);
arsServer.logout();
} catch (ARException e) {
e.printStackTrace();
arsServer.logout();
}
}
}
Here is the stacktrace:
Jun 20, 2017 4:11:55 PM java.util.prefs.WindowsPreferences openKey
WARNING: Could not open windows registry node Software\JavaSoft\Prefs at root 0x80000002. Windows RegOpenKey(...) returned error code 2.
Jun 20, 2017 4:11:55 PM java.util.prefs.WindowsPreferences closeKey
WARNING: Could not close windows registry node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCloseKey(...) returned error code 6.
**ERROR (91): RPC call failed; localhost:3389 Connection reset**
at com.bmc.arsys.apitransport.ApiProxyJRpcBase.convertException(ApiProxyJRpcBase.java:643)
at com.bmc.arsys.api.ProxyJRpc.getRpcClient(ProxyJRpc.java:135)
at com.bmc.arsys.api.ProxyJRpc.<init>(ProxyJRpc.java:67)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.bmc.arsys.apitransport.connection.ApiProxyFactory.createProxyInstance(ApiProxyFactory.java:89)
at com.bmc.arsys.apitransport.connection.ApiProxyFactory.createProxy(ApiProxyFactory.java:160)
at com.bmc.arsys.api.ProxyManager.createProxy(ProxyManager.java:602)
at com.bmc.arsys.api.ProxyPool.createProxy(ProxyPool.java:106)
at com.bmc.arsys.apitransport.connection.ApiProxyPool.get(ApiProxyPool.java:192)
at com.bmc.arsys.apitransport.connection.ApiProxyManager.getProxy(ApiProxyManager.java:210)
at com.bmc.arsys.api.PoolingProxyManager.getProxy(PoolingProxyManager.java:93)
at com.bmc.arsys.apitransport.connection.ApiProxyManager.getProxy(ApiProxyManager.java:164)
at com.bmc.arsys.api.ARServerUser.verifyUser(ARServerUser.java:1085)
at com.bmc.arsys.api.ARServerUser.login(ARServerUser.java:412)
at Remedi.RemedyCreateTicket.main(RemedyCreateTicket.java:46)
Thanks in advance.
This is old but for anyone looking at it after; the code looks fine. ARERROR 91 is typically a networking issue. Port 3389 is the default for Remote Desktop. Therefore, I wonder if you are tunneling to localhost and trying to connect to the Windows machine that you RDP to? Instead of the TCP port the AR Server is actually running on and let in through the Windows firewall?

OpenGTS Integration in Eclipse

OpenGTS Integration in Eclipse
*Imported whole opengts code in to the eclispse workspace.
*Created the four environment variables like GTS_HOME,CATALINA_HOME,ANT_HOME,JAVA_HOME as system variables.
*In the next step am trying to configure the database for the opengts as they mentioned in the document.
*Refer the link below
"http://opengts.sourceforge.net/OpenGTS_Config.pdf".
Taking reference of above link Am trying to run the commands given in the pdf file
*The first command we need to run is initdb.bat command in windows command prompt.
*When ever i run the above command the system dynasmically create the gts database and tables related to that db.
*At this moment am strucked with the error
"C:\OpenGTS_2.6.4\bin>initdb.bat
"C:\Program Files\Java\jdk1.8.0_45\bin\java" "-Dfile.encoding=UTF-8" -classpath "C:\OpenGTS_2.6.4\build\lib"\gtsdb.jar;"C:\OpenGTS_2.6.4\build\lib"\gtsutils.jar;"C:\OpenGTS_2.6.4\build\lib"\optdb.jar;"C:\OpenGTS_2.6.4\build\lib"\ruledb.jar;"C:\OpenGTS_2.6.4\build\lib"\bcrossdb.jar;"C:\OpenGTS_2.6.4\build\lib"\custom.jar;"C:\OpenGTS_2.6.4\build\lib"\dmtpserv.jar;"C:\OpenGTS_2.6.4\build\lib"\gtsdmtp.jar; org.opengts.db.DBConfig -conf:"C:\OpenGTS_2.6.4\default.conf" -log.file.enable:false -initTables
Version: 2.6.4
[ERROR|DBAdmin.execCommands:1006] SQLException message: Access denied for user 'root'#'localhost' (using password: NO)
[ERROR|DBAdmin.execCommands:1007] ==> SQLException: DB create error [jdbc:mysql://localhost:3306/]
[ERROR|DBAdmin.execCommands:1007] Message: Access denied for user 'root'#'localhost' (using password: NO)
[ERROR|DBAdmin.execCommands:1007] SQLState: 28000
[ERROR|DBAdmin.execCommands:1007] ErrorCode: 1045
[DBAdmin.execCommands:1007] java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: NO)
java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: NO)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3835)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3771)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:870)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1659)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1206)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2239)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2270)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2069)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:389)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at org.opengts.dbtools.DBConnection.getConnection(DBConnection.java:809)
at org.opengts.dbtools.DBConnection.createStatement(DBConnection.java:945)
at org.opengts.dbtools.DBConnection.createStatement(DBConnection.java:933)
at org.opengts.dbtools.DBConnection._executeUpdate(DBConnection.java:1188)
at org.opengts.dbtools.DBConnection.executeUpdate(DBConnection.java:1143)
at org.opengts.dbtools.DBConnection.executeUpdate(DBConnection.java:1124)
at org.opengts.dbtools.DBProvider.createDatabase(DBProvider.java:1699)
at org.opengts.dbtools.DBAdmin.execCommands(DBAdmin.java:995)
at org.opengts.db.DBConfig._main(DBConfig.java:2036)
at org.opengts.db.DBConfig.main(DBConfig.java:2180)"
*Am getting error in DBAdmin.Java class with two methods given in the opengts code.
The methods are
.............................(1)................................
public static DBFactory<? extends DBRecord<?>>[] getClassTableFactories(Class<?> tableClass)
{
java.util.List<DBFactory<? extends DBRecord<?>>> list = new Vector<DBFactory<? extends DBRecord<?>>>();
if (tableClass != null) {
for (DBFactory<? extends DBRecord<?>> tableFact : DBAdmin.getTableFactoryMap().values()) {
if (DBFactory.isTableClass(tableFact,tableClass)) {
list.add(tableFact);
}
}
}
#SuppressWarnings("unchecked")
DBFactory<? extends DBRecord<?>> dbf[] = list.toArray(new DBFactory<?>[list.size()]);
return dbf;
}
...........................(2).............................
if (RTConfig.hasProperty(ARG_LAST)) {
execCmd++;
//String last = RTConfig.getString(ARG_LAST, null);
Print.logInfo("Table last update time:");
OrderedMap<String,DBFactory<? extends DBRecord<?>>> factMap = DBAdmin.getTableFactoryMap();
for (Iterator<String> i = factMap.keyIterator(); i.hasNext();) {
String tn = i.next();
DBFactory<? extends DBRecord<?>> f = (DBFactory<? extends DBRecord<?>>)factMap.get(tn);
try {
long lut = DBRecord.getLastUpdateTime(f);
if (lut < 0L) {
Print.logInfo(" Last Table Update: " +tn + " - Not Available");
} else
if (lut == 0L) {
Print.logInfo(" Last Table Update: " + tn + " - No Data");
} else {
Print.logInfo(" Last Table Update: " + tn + " - " + (new DateTime(lut)));
//Print.logInfo(" => " + DBRecord.getRecordsSince(f, lut)[0]);
}
} catch (DBException dbe) {
Print.logError(" Last Table Update: " +tn + " - DB Error [" + dbe + "]");
}
}
}
In System.conf file You have to set Mysql database password same as localhost DB.Than try to Build the project.It will work.
You have to run initdb command like given below.
C:\OpenGTS_2.5.9\bin>initdb.bat "-rootUser:db root username" "-rootPass:db rootpassword"
Result should be like this:
Validating table columns ...
Table 'Account' 1 Validating columns ...
continue..
I have checked the username and password ..Even though it is giving the same error when am trying to run the initdb.bat in the command prompt as follows
C:\OpenGTS_2.6.4\bin>initdb.bat
"C:\Program Files\Java\jdk1.8.0_45\bin\java" "-Dfile.encoding=UTF-8" -classpath
"C:\OpenGTS_2.6.4\build\lib"\gtsdb.jar;"C:\OpenGTS_2.6.4\build\lib"\gtsutils.jar;"C:\OpenGTS_2.6.4\build\lib"\optdb.jar;"C:\OpenGTS_2.6.4\build\lib"\ruledb.jar;"C:\OpenGTS_2.6.4\build\lib"\bcrossdb.jar;"C:\OpenGTS_2.6.4\build\lib"\custom.jar;"C:\OpenGTS_2.6.4\build\lib"\dmtpserv.jar;"C:\OpenGTS_2.6.4\build\lib"\gtsdmtp.jar; org.opengts.db.DBConfig -conf:"C:\OpenGTS_2.6.4\default.conf"
-log.file.enable:false -initTables
Version: 2.6.4
[ERROR|DBAdmin.execCommands:1006] SQLException message: Access denied for user 'root'#'localhost' (using password: NO)
[ERROR|DBAdmin.execCommands:1007] ==> SQLException: DB create error [jdbc:mysql://localhost:3306/]
[ERROR|DBAdmin.execCommands:1007] Message: Access denied for user 'root'#'localhost' (using password: NO)
[ERROR|DBAdmin.execCommands:1007] SQLState: 28000
[ERROR|DBAdmin.execCommands:1007] ErrorCode: 1045
[DBAdmin.execCommands:1007] java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: NO)
java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: NO)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3835)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3771)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:870)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1659)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1206)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2239)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2270)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2069)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:389)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at org.opengts.dbtools.DBConnection.getConnection(DBConnection.java:809)
at org.opengts.dbtools.DBConnection.createStatement(DBConnection.java:945)
at org.opengts.dbtools.DBConnection.createStatement(DBConnection.java:933)
at org.opengts.dbtools.DBConnection._executeUpdate(DBConnection.java:1188)
at org.opengts.dbtools.DBConnection.executeUpdate(DBConnection.java:1143)
at org.opengts.dbtools.DBConnection.executeUpdate(DBConnection.java:1124)
at org.opengts.dbtools.DBProvider.createDatabase(DBProvider.java:1699)
at org.opengts.dbtools.DBAdmin.execCommands(DBAdmin.java:995)
at org.opengts.db.DBConfig._main(DBConfig.java:2036)
at org.opengts.db.DBConfig.main(DBConfig.java:2180)
"C:\OpenGTS_2.6.4\bin>initdb.bat -rootUser=<logindb> -rootPass=<dbpassword>

java + app engine + cloudSQL + spring/hibernate

I am using Spring Hibernate with app engine and cloudSQL for my project but i am getting one error frequently. This occurs when application becomes ideal for sometimes.
For every query (fetching or save/update to database), i open session and close session after its use. like this --
My code for database fetching is
try{
Session session = getSessionFactory().openSession();
if(session != null)
{
List<Account> accounts = session.createQuery("from " + this.clazz.getName() + " where subDomainName = '"+subDomain+"'").list();
session.close();
if(accounts != null)
{
if(accounts.size()>0){
return accounts.get(0);
}
else{
return null;
}
}
else
{
return null;
}
}
else {
return null;
}
}
catch(Exception e){
log.info("Error in retriving subdomain details :: in Account Dao");
return null;
}
I am using Autowired structuring. but when application becomes ideal for sometime and after some time when i refresh page its display the error as Stream Closed of CloudSQL on app engine, error is shown below...
Error is :
6 Jan, 2014 6:21:04 AM com.google.appengine.repackaged.org.apache.http.impl.client.DefaultRequestDirector handleResponse
WARNING: Authentication error: Unable to respond to any of these challenges: {bearer=WWW-Authenticate: Bearer realm="https://www.google.com/accounts/AuthSubRequest", error=invalid_token}
6 Jan, 2014 6:21:04 AM com.google.appengine.api.rdbms.dev.LocalRdbmsServiceRemoteDriver openConnection
WARNING: openConnection
java.sql.SQLException: Stream closed
at com.google.cloud.sql.jdbc.internal.googleapi.RpcGoogleApi.newOpenConnectionIOException(RpcGoogleApi.java:187)
at com.google.cloud.sql.jdbc.internal.googleapi.RpcGoogleApi.openConnection(RpcGoogleApi.java:105)
at com.google.appengine.api.rdbms.dev.LocalRdbmsServiceRemoteDriver.openConnection(LocalRdbmsServiceRemoteDriver.java:206)
at com.google.appengine.api.rdbms.dev.LocalRdbmsService.openConnection(LocalRdbmsService.java:119)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.callInternal(ApiProxyLocalImpl.java:498)
at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:452)
at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:430)
at java.util.concurrent.Executors$PrivilegedCallable$1.run(Executors.java:461)
at java.security.AccessController.doPrivileged(Native Method)
at java.util.concurrent.Executors$PrivilegedCallable.call(Executors.java:458)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.io.IOException: Stream closed
at java.util.zip.GZIPInputStream.ensureOpen(GZIPInputStream.java:42)
at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:85)
For this to engage app engine and cloudSQL i have wriiten cron job of certains request but this is not feasible solution, i can not gets why cloudSQL closes its stream for app engine.

Activating a user account on creation in AD LDS

So, I'm writing code that will create user accounts in AD LDS. I can create the user, but the account is disabled.
I want the user to be active and to be able to change their password. I've tried some of the things suggested in this post, but it hasn't helped me.
Here's my code:
ctx = getConnection(adminUser, adminPassword);
// Create attributes for the new user
Attributes attributes = new BasicAttributes(true);
// Main attributes for user
attributes.put("objectClass", "user");
attributes.put("name", user.getFullName());
attributes.put("ms-DS-User-Account-Control-Computed",
Integer.toString(UF_NORMAL_ACCOUNT + UF_PASSWORD_EXPIRED));
try {
ctx.createSubcontext(getDistinguishedName(user.getFullName()),
attributes);
System.out.println("User successfully added!");
} catch (NamingException e) {
e.printStackTrace();
}
When I run this, I get the following error:
javax.naming.directory.NoSuchAttributeException: [LDAP: error code 16
- 00000057: LdapErr: DSID-0C090D11, comment: Error in attribute conversion operation, data 0, v23f0remaining name 'CN=Samuel
King,CN=Users,CN=Agents,DC=CHESA,DC=local' at
com.sun.jndi.ldap.LdapCtx.mapErrorCode(Unknown Source) at
com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source) at
com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source) at
com.sun.jndi.ldap.LdapCtx.c_createSubcontext(Unknown Source) at
com.sun.jndi.toolkit.ctx.ComponentDirContext.p_createSubcontext(Unknown
Source) at
com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.createSubcontext(Unknown
Source) at
com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.createSubcontext(Unknown
Source) at
javax.naming.directory.InitialDirContext.createSubcontext(Unknown
Source) at
com.ceiwc.ActiveDirectory.createUserAccount(ActiveDirectory.java:114)
at com.ceiwc.TestAD.main(TestAD.java:24)
If I change the line where I'm updating the ms-DS-User-Account-Control-Computed to:
attributes.put("ms-DS-User-Account-Control-Computed", UF_NORMAL_ACCOUNT
+ UF_PASSWORD_EXPIRED);
i get the following error:
javax.naming.directory.InvalidAttributeValueException: Malformed
'ms-DS-User-Account-Control-Computed' attribute value; remaining name
'CN=Samuel King,CN=Users,CN=Agents,DC=CHESA,DC=local' at
com.sun.jndi.ldap.LdapClient.encodeAttribute(Unknown Source) at
com.sun.jndi.ldap.LdapClient.add(Unknown Source) at
com.sun.jndi.ldap.LdapCtx.c_createSubcontext(Unknown Source) at
com.sun.jndi.toolkit.ctx.ComponentDirContext.p_createSubcontext(Unknown
Source) at
com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.createSubcontext(Unknown
Source) at
com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.createSubcontext(Unknown
Source) at
javax.naming.directory.InitialDirContext.createSubcontext(Unknown
Source) at
com.ceiwc.ActiveDirectory.createUserAccount(ActiveDirectory.java:116)
at com.ceiwc.TestAD.main(TestAD.java:24)
So, what am I doing wrong? Is this the proper way to activate the account? Does someone have any code to help me out?
Thanks!
NuAlphaMan,
I think, that the exception has something to do with the fact that you use CN as the name of the attribute instead of Ldap-Display-Name which is msDS-User-Account-Control-Computed. The description could be found here http://msdn.microsoft.com/en-us/library/windows/desktop/ms677840(v=vs.85).aspx.
As to the second question of how to activate an account, I've found that there is an attribute userAccountControl (http://msdn.microsoft.com/en-us/library/windows/desktop/ms680832(v=vs.85).aspx#win_2008_r2) and the value 0x00000002 (ADS_UF_ACCOUNTDISABLE) that can disable an account. The only thing that crosses my mind is to try to read the value and flip the bit.
Regards, Dmitry
NoSuchAttributeException: "Indicates that the attribute specified in the modify or compare operation does not exist in the entry."
Malformed 'ms-DS-User-Account-Control-Computed' attribute value: means wrong attribute type.
here is my working example, that i check with ActiveDirectory 2008:
public void mapToContext(int userAccountControl, DirContextAdapter context) {
context.setAttributeValue("userAccountControl", disableAccount(userAccountControl));
}
private String disableAccount(int userAccountControl) {
userAccountControl |= AccountControlFlags.ACCOUNTDISABLE;
return String.valueOf(userAccountControl);
}

Categories

Resources