I'm trying to enable a user in the Active Directory with LDAP and Java (1.4).
However I keep getting the following error:
java.lang.NullPointerException at
com.sun.jndi.ldap.LdapCtx.c_modifyAttributes(LdapCtx.java:1432) at
com.sun.jndi.toolkit.ctx.ComponentDirContext.p_modifyAttributes(ComponentDir
Context.java:255) at
com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.modifyAttributes(Partial
CompositeDirContext.java:172) at
com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.modifyAttributes(Partial
CompositeDirContext.java:161) at
javax.naming.directory.InitialDirContext.modifyAttributes(InitialDirContext.
java:146) at be.ideal.LDAP.newuser.main(newuser.java:61) Exception in
thread "main"
I already confirmed that my user has a password, I just can't seem to change his status to active
My code:
public static void main(String[] args) {
String userName = "cn=Albert Einstein,ou=Accounts,DC=PORTAL,DC=COMPANY,DC=BE";
String groupName = "cn=Administrators,cn=Roles,DC=PORTAL,DC=COMPANY,DC=BE";
boolean isDisabled = false;
try {
System.out.println("Creating initial directory context...");
LdapContext ctx = new InitialLdapContext(X_Ldap.getEnvironment(),
null);
Attributes attrs = new BasicAttributes(true);
attrs.put("objectClass", "user");
attrs.put("cn", "Albert Einstein");
String newQuotedPassword = "\"Pass123\"";
byte[] newUnicodePassword = newQuotedPassword.getBytes("UTF-16LE");
attrs.put(new BasicAttribute("unicodePwd", newUnicodePassword));
attrs.put(new BasicAttribute("msDS-UserAccountDisabled", "FALSE"));
System.out.println("Creating context...");
Context result = ctx.createSubcontext(userName, attrs);
System.out.println("Created account for: " + userName);
System.out.println("Creating context...");
Context result = ctx.createSubcontext(userName, attrs);
System.out.println("Created account for: " + userName);
try {
ModificationItem member[] = new ModificationItem[1];
member[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE,
new BasicAttribute("member", userName));
ctx.modifyAttributes(groupName, member);
System.out.println("Added user to group: " + groupName);
} catch (NamingException e) {
System.err.println("Problem adding user to group: " + e);
}
ctx.close();
System.out.println("Successfully created User: " + userName);
} catch (NamingException e) {
System.err.println("Problem creating object: " + e);
}
catch (IOException e) {
System.err.println("Problem creating object: " + e);
}
}
PS: I am using AD LDS for my active directory
Found it:
Needed to use DirContext.ADD_ATTRIBUTE instead of DirContext.REPLACE_ATTRIBUTE
Related
Below is the code Snippet.. that must call WSDL in other server dynamically
but in the moment of calling
(int i = webServiceModuleService.notificationRecieved("xyz");)
returned exception :(
note: i haven't any beaInvoke method in my service :|
public static void main(String[] args) {
java.sql.Connection conn = null;
InitialContext context;
try {
context = new InitialContext();
DataSource ds = (DataSource) context.lookup("jdbc/dataSourceDS");
conn = ds.getConnection();
} catch (SQLException e) {
} catch (NamingException e) {
}
QueryRunner run = new QueryRunner();
SampleResultSetHandler h = new SampleResultSetHandler();
Object[] res = null;
try {
res = run.query(conn, "select SERVER_IP,SERVER_PORT from SERVER where UPPER(SERVER_NAME)=? ", h, "test");
} catch (SQLException e) {
}
String ip = res[0].toString();
String port = res[1].toString();
String endpointURL = "http://" + ip + ":" + port + "/context-root/WebServiceModuleService";
try {
URL tmpURL = new URL(endpointURL + "?wsdl");
System.err.println(tmpURL);
WebServiceModuleService_Service webServiceModuleService_Service = new WebServiceModuleService_Service(tmpURL,
new QName("/org/parsisys/test/mina/model/services/common/",
"WebServiceModuleService"));
WebServiceModuleService webServiceModuleService = null;
webServiceModuleService = webServiceModuleService_Service.getWebServiceModuleServiceSoapHttpPort();
BindingProvider bp = (BindingProvider) webServiceModuleService;
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL);
// Configure credential providers
Map<String, Object> requestContext = ((BindingProvider) webServiceModuleService).getRequestContext();
try {
setPortCredentialProviderList(requestContext);
} catch (Exception ex) {
ex.printStackTrace();
}
//Call WebService ... ==> Exception :(
int i = webServiceModuleService.notificationRecieved("xyz");
//logp("successfully call the webservice for [ip&port:" + ip + ":" + port + "] [transid : " +transid + "]");
} catch (Exception e) {
//log
//TODO: Clean This
System.err.println(e.getMessage());
e.printStackTrace();
return;
}
}
#Generated("Oracle JDeveloper")
public static void setPortCredentialProviderList(Map<String, Object> requestContext) throws Exception {
// TODO - Provide the required credential values
String username = "";
String password = "";
String clientKeyStore = "";
String clientKeyStorePassword = "";
String clientKeyAlias = "";
String clientKeyPassword = "";
String serverKeyStore = "";
String serverKeyStorePassword = "";
String serverKeyAlias = "";
List<CredentialProvider> credList = new ArrayList<CredentialProvider>();
// Add the necessary credential providers to the list
// Code commented out due to empty username/password value found in the credential.
// credList.add(getUNTCredentialProvider(username, password));
// Code commented out due to empty server keystore value found in the credential.
// credList.add(getBSTCredentialProvider(clientKeyStore, clientKeyStorePassword, clientKeyAlias, clientKeyPassword, serverKeyStore, serverKeyStorePassword, serverKeyAlias, requestContext));
credList.add(getSAMLTrustCredentialProvider());
requestContext.put(WSSecurityContext.CREDENTIAL_PROVIDER_LIST, credList);
}
#Generated("Oracle JDeveloper")
public static CredentialProvider getSAMLTrustCredentialProvider() {
return new SAMLTrustCredentialProvider();
}
daynamic webservice call is generated with jdeveloper and it's works in clien't tester but in my module when i call webservice return exception :/
StackTrace is: ↓
Method beaInvoke is exposed as WebMethod, but there is no corresponding wsdl operation with name {/org/parsisys/test/mina/model/services/common/}beaInvoke in the wsdl:portType{/org/parsisys/test/mina/model/services/common/}WebServiceModuleService
javax.xml.ws.WebServiceException: Method beaInvoke is exposed as WebMethod, but there is no corresponding wsdl operation with name {/org/parsisys/test/mina/model/services/common/}beaInvoke in the wsdl:portType{/org/parsisys/test/mina/model/services/common/}WebServiceModuleService
at com.sun.xml.ws.model.JavaMethodImpl.freeze(JavaMethodImpl.java:382)
at com.sun.xml.ws.model.AbstractSEIModelImpl.freeze(AbstractSEIModelImpl.java:124)
at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:336)
at com.sun.xml.ws.db.DatabindingImpl.(DatabindingImpl.java:99)
at com.sun.xml.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:74)
at com.sun.xml.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:58)
at com.sun.xml.ws.db.DatabindingFactoryImpl.createRuntime(DatabindingFactoryImpl.java:120)
at com.sun.xml.ws.client.WSServiceDelegate.buildRuntimeModel(WSServiceDelegate.java:882)
at com.sun.xml.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:899)
at com.sun.xml.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:862)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:451)
at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegateImpl.internalGetPort(WLSProvider.java:1698)
at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegateImpl$PortClientInstanceFactory.createClientInstance(WLSProvider.java:1769)
at weblogic.wsee.jaxws.spi.ClientInstancePool.takeSimpleClientInstance(ClientInstancePool.java:389)
at weblogic.wsee.jaxws.spi.ClientInstancePool.take(ClientInstancePool.java:243)
at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegateImpl$3.apply(WLSProvider.java:1555)
at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegateImpl$3.apply(WLSProvider.java:1517)
at weblogic.wsee.jaxws.spi.ClientIdentityRegistry.initClientIdentityFeatureAndCall(ClientIdentityRegistry.java:1456)
at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegateImpl.getPort(WLSProvider.java:1513)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:420)
at weblogic.wsee.jaxws.spi.WLSProvider$ServiceDelegateImpl.getPort(WLSProvider.java:1477)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:402)
at javax.xml.ws.Service.getPort(Service.java:119)
at org.parsisys.test.mina.model.service.WebServiceModuleService_Service.beaInvokeSuper(WebServiceModuleService_Service.java)
at org.parsisys.test.mina.model.service.WebServiceModuleService_Service$beaVersion0_31.getWebServiceModuleServiceSoapHttpPort(WebServiceModuleService_Service.java:51)
at org.parsisys.test.mina.model.service.WebServiceModuleService_Service.getWebServiceModuleServiceSoapHttpPort(WebServiceModuleService_Service.java)
at org.parsisys.test.mina.files.notification.queue.NotificationQueueRecieved$beaVersion0_11.onMessage(NotificationQueueRecieved.java:330)
at org.parsisys.test.mina.files.notification.queue.NotificationQueueRecieved.onMessage(NotificationQueueRecieved.java)
at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:5107)
at weblogic.jms.client.JMSSession.execute(JMSSession.java:4775)
at weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:4170)
at weblogic.jms.client.JMSSession.access$000(JMSSession.java:127)
at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5627)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:666)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)
please help me. tnx
For me this occurs when the WSDL does not agree with the generated classes.
I want to use Java PayPal SDK to get account history. I tried this simple code:
public void randomDatabaseData() throws SQLException, FileNotFoundException, IOException, PayPalRESTException {
String clientID = "test";
String clientSecret = "test";
String accessToken = null;
try {
Map<String, String> map = new HashMap<String, String>();
map.put("mode", "live");
try {
accessToken = new OAuthTokenCredential(clientID, clientSecret, map).getAccessToken();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(accessToken);
transactionSearch(accessToken);
} catch (Exception e) {
e.printStackTrace();
}
}
public TransactionSearchResponseType transactionSearch(String accessToken) {
TransactionSearchReq transactionSearchReq = new TransactionSearchReq();
TransactionSearchRequestType transactionSearchRequest = new TransactionSearchRequestType(
"2012-12-25T00:00:00+0530");
transactionSearchReq.setTransactionSearchRequest(transactionSearchRequest);
PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();
service.setTokenSecret(accessToken);
TransactionSearchResponseType transactionSearchResponse = null;
try {
transactionSearchResponse = service.transactionSearch(transactionSearchReq);
} catch (Exception e) {
System.out.println("Error Message : " + e.getMessage());
}
if (transactionSearchResponse.getAck().getValue().equalsIgnoreCase("success")) {
Iterator<PaymentTransactionSearchResultType> iterator = transactionSearchResponse
.getPaymentTransactions().iterator();
while (iterator.hasNext()) {
PaymentTransactionSearchResultType searchResult = iterator.next();
System.out.println("Transaction ID : " + searchResult.getTransactionID());
}
} else {
List<ErrorType> errorList = transactionSearchResponse.getErrors();
System.out.println("API Error Message : " + errorList.get(0).getLongMessage());
}
return transactionSearchResponse;
}
But I get his error stack when I run the code:
Error Message : configurationMap cannot be null
java.lang.NullPointerException
at com.crm.web.tickets.GenearateTicketsTest.transactionSearch(GenearateTicketsTest.java:161)
at com.crm.web.tickets.GenearateTicketsTest.randomDatabaseData(GenearateTicketsTest.java:139)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
How I can fix this code? I configure client ID and secret key into PayPal web site but still I get error.
I recommend you using TransactionSearch API to get the payment history based on your search date range.
DirContext ldapContext;
String baseName = "dc=MyCompany,dc=com";
String serverIP = "xx.xxx.xxx.xxx";
public ADConnection() {
try {
Hashtable ldapEnv = new Hashtable(11);
ldapEnv.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
ldapEnv.put(Context.PROVIDER_URL, "ldap://xx.xx.xx.xx:389");
ldapEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
ldapEnv.put(Context.SECURITY_PRINCIPAL, "cn=Directory Manager");
ldapEnv.put(Context.SECURITY_CREDENTIALS, "xxxx");
ldapContext = new InitialDirContext(ldapEnv);
System.out.println(ldapContext);
}
catch (Exception e) {
System.out.println(" bind error: " + e);
e.printStackTrace();
System.exit(-1);
}
}
public void createNew(String username, String surname, String givenName) {
try {
String distinguishedName = "cn=" + username + baseName;
Attributes newAttributes = new BasicAttributes(true);
Attribute oc = new BasicAttribute("objectclass");
oc.add("top");
oc.add("person");
oc.add("organizationalperson");
oc.add("user");
newAttributes.put(oc);
newAttributes.put(new BasicAttribute("sAMAccountName", username));
newAttributes.put(new BasicAttribute("userPrincipalName", username + "#" + serverIP));
newAttributes.put(new BasicAttribute("cn", username));
newAttributes.put(new BasicAttribute("sn", surname));
newAttributes.put(new BasicAttribute("givenName", givenName));
newAttributes.put(new BasicAttribute("displayName", givenName + " " + surname));
System.out.println("Name: " + username + " Attributes: " + newAttributes);
ldapContext.createSubcontext(distinguishedName, newAttributes);
}
catch (Exception e) {
System.out.println("create error: " + e);
e.printStackTrace();
System.exit(-1);
}
}
public Attributes fetch(String username) {
Attributes attributes = null;
try {
System.out.println("fetching: " + username);
DirContext o = (DirContext)ldapContext.lookup("cn=" + username+ baseName);
System.out.println("search done\n");
attributes = o.getAttributes("");
for (NamingEnumeration ae = attributes.getAll(); ae.hasMoreElements();) {
Attribute attr = (Attribute)ae.next();
String attrId = attr.getID();
for (NamingEnumeration vals = attr.getAll(); vals.hasMore();) {
String thing = vals.next().toString();
System.out.println(attrId + ": " + thing);
}
}
}
catch (Exception e) {
System.out.println(" fetch error: " + e);
System.exit(-1);
}
return attributes;
}
public static void main(String[] args) {
adc.createNew("user1,", "User", "user1");
Attributes a = adc.fetch("user1,");
}
while creating user and after fetching user I am getting below error in the console.
javax.naming.directory.InitialDirContext#18eb9e6
Name: user1, Attributes: {displayname=displayName: user1 User, givenname=givenName: user1,
objectclass=objectclass: top, person, organizationalperson, user,
samaccountname=sAMAccountName: user1,, sn=sn: User, userprincipalname=userPrincipalName:
user1,#xx.xxx.xxx.xxx, cn=cn: user1,}
create error: javax.naming.NameNotFoundException: [LDAP: error code 32 - The provided entry
cn=user1,dc=MyCompany,dc=com cannot be added because its suffix is not defined as one of the
suffixes within the Directory Server]; remaining name 'cn=user1,dc=MyCompany,dc=com'
javax.naming.NameNotFoundException: [LDAP: error code 32 - The provided entry
cn=user1,dc=MyCompany,dc=com cannot be added because its suffix is not defined as one of the
suffixes within the Directory Server]; remaining name 'cn=user1,dc=MyCompany,dc=com'
Does the backend for dc=mycompany,dc=com exist? If not, you must create it and populate with, at a minimum, the base object dc=mycompany,dc=com.
I'm trying to get the elements out of a namingenumeration.
The namingenumeration itself is not null, but hasNext() gives me false.
What am I doing wrong?
public static void main(String[] args) {
try {
DirContext context = new InitialDirContext(
Environment.getEnvironment());
SearchControls controls = new SearchControls();
controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
String[] attrIDs = { "cn", "givenname", "sn", "mail" };
controls.setReturningAttributes(attrIDs);
NamingEnumeration enumResult = context.search(
"DC=PORTAL,DC=COMPANY,DC=BE", "(CN=*)",
controls);
System.out.println(enumResult.hasMore());
context.close();
} catch (AuthenticationException e) {
System.out.println("Invalid credentials");
} catch (NamingException e) {
System.out.println("Lookup failed: " + e);
}
}
Structure of AD (on Localhost using AD-LDS)
DC=PORTAL,DC=COMPANY,DC=BE
->OU=Accounts
==>CN=John Doe
==>CN=Jane Doe
->CN=LostAndFound
->CN=NTDS Quotas
->CN=Roles
->OU=System Accounts
==>CN=PortalAdmin
Narrowing my searchbase to "OU=ACCOUNTS,DC=PORTAL,DC=COMPANY,DC=BE" gives the following error
Lookup failed: javax.naming.NameNotFoundException: [LDAP: error code
32 - 000020 8D: NameErr: DSID-031522C9, problem 2001 (NO_OBJECT), data
0, best match of: 'DC=PORTAL,DC=COMPANY,DC=BE' ]; remaining name 'OU=ACCOUNTS,DC=PORTAL,DC=COMPANY,DC=BE'
solution:
try {
DirContext ctx = new InitialDirContext(Environment.getEnvironment());
// Get all the attributes of named object
Attributes attrs = ctx
.getAttributes("cn=John Doe,ou=Accounts,DC=PORTAL,DC=COMPANY,DC=BE");
if (attrs == null) {
System.out.println("No attributes");
} else {
/* Print each attribute */
try {
for (NamingEnumeration ae = attrs.getAll(); ae.hasMore();) {
Attribute attr = (Attribute) ae.next();
System.out.println("attribute: " + attr.getID());
/* print each value */
for (NamingEnumeration e = attr.getAll(); e.hasMore(); System.out
.println("value: " + e.next()))
;
}
} catch (NamingException e) {
e.printStackTrace();
}
}
ctx.close();
} catch (AuthenticationException e) {
System.out.println("Invalid credentials");
} catch (NamingException e) {
System.out.println("Lookup failed: " + e);
}
Start with doing some basic sanity checks. For instance, that the data returned by Environment.getEnvironment() is correct (url, port, user, password) and allows a connection to the directory server. Also check that there are no network problems and that you can, in fact, access the server.
Try limiting the search base a bit more, for instance: "OU=Accounts,DC=PORTAL,DC=COMPANY,DC=BE" and see if some results are returned. Also check if the objects in the expected results actually have the attributes "cn", "givenname", "sn", "mail".
Other than that, there are no obvious mistakes in the code shown in the question, it should work fine.
I am having some trouble with the HashMaps in my program. I have several declared at the top class like so:
public HashMap<String, Object> hmClass = new HashMap<String ,Object>();
public HashMap<String, Object> hmIns = new HashMap<String, Object>();
public HashMap<String, Object> hmCon = new HashMap<String, Object>();
public HashMap<String, Object> hmParam = new HashMap<String, Object>();
public HashMap<String, Object> hmResult = new HashMap<String, Object>();
In a separate method, I am putting values into them like this:
public String newInstanceCreate(Class c3, String classInstance)//void ??
{
Class c = c3;
String cI = classInstance;
Object instance = null;
Object con = null;
String instanceName = null;
try{
instanceName = JOptionPane.showInputDialog(null, "Under what name would you like to store this Instance?",
"Create an Instance of a Class", JOptionPane.QUESTION_MESSAGE);
}catch(NullPointerException e)
{
newInstanceCreate(c,cI);
}
hmClass.put(instanceName, c); //add the name of the instance as key and class as value to the hashmap
System.out.println(hmClass);
con = JOptionPane.showInputDialog(null,"Choose Constructor for " + c, "Create an Instance of a Class", 3, null, getConstructors(c), JOptionPane.QUESTION_MESSAGE);
System.out.println("worked + " + con);
hmCon.put(instanceName, con); //add the name of the instance as key and constructor as value to the hashmap
System.out.println(hmCon);
try {
instance = c3.getDeclaredConstructor().newInstance(); //create the instance --KEY
hmIns.put(instanceName, instance);
System.out.println("23" + instance);
hmParam.put(instanceName, getParams(c3, con)); //ask the user for the parameters (doubles) that they want in the instance constructor
// add the name of the instance as key and parameters(array) as value
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e){
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
System.out.print("hmClass: \n" + hmClass + "hmIns: \n" + hmIns + "hmCon: \n" + hmCon + "hmParam: \n" + hmParam);
return classInstance;
}
But when I try access them from a another method, it seems that they have all been reset.
public void option4()
{
System.out.println("hmIns: " + hmIns);
String stringInstance = JOptionPane.showInputDialog(null, "Which Instance would you like to stringify? " ,
"Stringify an Instance of a Class", JOptionPane.QUESTION_MESSAGE);
//get all the required info for making the instance
/*
* needed: name of stored instance
* name of correct and stored constructor
* name of parameters that were created by user (doubles?)
*/
System.out.println(stringInstance);
if(hmIns.isEmpty())
System.out.println("EMPTY");
Object ins = hmIns.get(stringInstance);
System.out.println("ins before: " + ins);
Object cons = hmCon.get(stringInstance);
System.out.println("cons before: " + cons);
Object par = hmParam.get(stringInstance);
System.out.println("par before: " + par);
//construct an instance and run toString() here
try {
ins = ((Constructor)cons).newInstance(par);
System.out.println(" ins: " + ins);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
//result from toString
/*
* stored: name of result
* result itself (stored as string for now)
*/
JOptionPane.showMessageDialog(null, "result here??--how to get result to double??", "Stringified Instance of: ", 0);
mainWindow();
}
In the last method listed, I tested to see if the HashMap had null values instead of actually being empty, but it returns as having no values at all. Why is the HashMap resetting after I exit the first method?
Thank you so much for any insight.
Fran
It doesn't reset. I suggest you look at your code in a debugger and check if they are looking at the same object/map. I suspect you have two objects which contain maps.