Byte Buddy Nested Annotations - byte-buddy

I would like to use Byte-Buddy to generate annotations and I am able to accomplish this for simple annotations. What is the correct Byte-Buddy syntax to generate nested annotations?
For example I would like to generate the following annotation #MessageDriven which contains nested annotations:
#MessageDriven(
activationConfig={
#ActivationConfigProperty(propertyName="destination", propertyValue="remoteBidsWantedJMS/TOPIC.BIDSWANTED.QUOTEWANTEDSEVENT"),
#ActivationConfigProperty(propertyName="providerAdapterJNDI", propertyValue="java:/RemoteBidsWantedJMSProvider"),
#ActivationConfigProperty(propertyName="reconnectAttempts", propertyValue="60"),
#ActivationConfigProperty(propertyName="reconnectInterval", propertyValue="10"),
#ActivationConfigProperty(propertyName="acknowledgeMode", propertyValue="Auto-acknowledge"),
#ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Topic"),
#ActivationConfigProperty(propertyName="subscriptionDurability", propertyValue="NonDurable"),
#ActivationConfigProperty(propertyName="maxSession", propertyValue="1")
})
What is wrong with my current syntax?
DynamicType.Unloaded dynamicTypeBuilder2 = new ByteBuddy()
.redefine(QuoteWantedsEventProcessorBean.class)
.name("com.tmcbonds.messaging.QuoteWantedsEventProcessorBean_BYTEBUDDY_REDEFINE_" + i)
.annotateType(AnnotationDescription.Builder.ofType(Pool.class)
.define("value", "TESTVALUE")
.build())
.annotateType(AnnotationDescription.Builder.ofType(MessageDriven.class)
.defineTypeArray("activationConfig", ActivationConfigProperty.class)
.define("propertyName", "destination")
.define("propertyValue", "remoteBidsWantedJMS/TOPIC.BIDSWANTED.QUOTEWANTEDSEVENT")
.build())
.make();
Exception is this:
Exception in thread "main" java.lang.IllegalArgumentException: [interface javax.ejb.ActivationConfigProperty] cannot be assigned to activationConfig
at net.bytebuddy.description.annotation.AnnotationDescription$Builder.define(AnnotationDescription.java:852)
at net.bytebuddy.description.annotation.AnnotationDescription$Builder.defineTypeArray(AnnotationDescription.java:1041)
at net.bytebuddy.description.annotation.AnnotationDescription$Builder.defineTypeArray(AnnotationDescription.java:1029)
Thanks!

I was able to figure out the correct syntax to create the class file with the nested annotations:
Unloaded<QuoteWantedsEventProcessorBean> dynamicTypeBuilder = new ByteBuddy()
.redefine(QuoteWantedsEventProcessorBean.class)
.name("com.tmcbonds.messaging.QuoteWantedsEventProcessorBean_BYTEBUDDY_REDEFINE_" + i)
.annotateType(AnnotationDescription.Builder.ofType(MessageDriven.class)
.defineAnnotationArray(
"activationConfig",
new TypeDescription.ForLoadedType(ActivationConfigProperty.class),
AnnotationDescription.Builder.ofType(ActivationConfigProperty.class)
.define("propertyName", "messageSelector")
.define("propertyValue", "" + i)
.build(),
AnnotationDescription.Builder.ofType(ActivationConfigProperty.class)
.define("propertyName", "destination")
.define("propertyValue", "remoteBidsWantedJMS/TOPIC.BIDSWANTED.QUOTEWANTEDSEVENT")
.build(),
AnnotationDescription.Builder.ofType(ActivationConfigProperty.class)
.define("propertyName", "providerAdapterJNDI")
.define("propertyValue", "java:/RemoteBidsWantedJMSProvider")
.build(),
AnnotationDescription.Builder.ofType(ActivationConfigProperty.class)
.define("propertyName", "reconnectAttempts")
.define("propertyValue", "60")
.build(),
AnnotationDescription.Builder.ofType(ActivationConfigProperty.class)
.define("propertyName", "reconnectInterval")
.define("propertyValue", "10")
.build(),
AnnotationDescription.Builder.ofType(ActivationConfigProperty.class)
.define("propertyName", "acknowledgeMode")
.define("propertyValue", "Auto-acknowledge")
.build(),
AnnotationDescription.Builder.ofType(ActivationConfigProperty.class)
.define("propertyName", "destinationType")
.define("propertyValue", "javax.jms.Topic")
.build(),
AnnotationDescription.Builder.ofType(ActivationConfigProperty.class)
.define("propertyName", "subscriptionDurability")
.define("propertyValue", "NonDurable")
.build(),
AnnotationDescription.Builder.ofType(ActivationConfigProperty.class)
.define("propertyName", "maxSession")
.define("propertyValue", "1")
.build()
)
.build())
.make();
Which generates the following in the class file:
#MessageDriven(description = "", activationConfig = {
#ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "0"),
#ActivationConfigProperty(propertyName = "destination", propertyValue = "remoteBidsWantedJMS/TOPIC.BIDSWANTED.QUOTEWANTEDSEVENT"),
#ActivationConfigProperty(propertyName = "providerAdapterJNDI", propertyValue = "java:/RemoteBidsWantedJMSProvider"),
#ActivationConfigProperty(propertyName = "reconnectAttempts", propertyValue = "60"),
#ActivationConfigProperty(propertyName = "reconnectInterval", propertyValue = "10"),
#ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
#ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
#ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "NonDurable"),
#ActivationConfigProperty(propertyName = "maxSession", propertyValue = "1") }, mappedName = "", messageListenerInterface = Object.class, name = "")

Related

Get trending topics of twitter api with C#

I get "401 Unauthorized" error while trying to get the current trends using the twitter api but the below code work fine if I try to get some other response like user_timeline,available,tweets. Below is my code please tell me where iam wrong.
var oauth_token = "****";
var oauth_token_secret = "****";
var oauth_consumer_key = "****";
var oauth_consumer_secret = "****";
// oauth implementation details
var oauth_version = "1.0";
var oauth_signature_method = "HMAC-SHA1";
// unique request details
var oauth_nonce = Convert.ToBase64String(
new ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString()));
var timeSpan = DateTime.UtcNow
- new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
var oauth_timestamp = Convert.ToInt64(timeSpan.TotalSeconds).ToString();
// message api details
var status = "Updating status via REST API if this works";
//var resource_url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
//var resource_url = "https://api.twitter.com/1.1/search/tweets.json";
// var resource_url = "https://api.twitter.com/1.1/trends/place.json";
var resource_url = "https://api.twitter.com/1.1/trends/available.json";
//var screen_name = "screenname";
var query = "india";
var id = "1";
// create oauth signature
//var baseFormat = "oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}" +
// "&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}&screen_name={6}";
//var baseFormat = "oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}" +
//"&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}&q={6}";
var baseFormat = "oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}" +
"&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}&id={6}";
var baseString = string.Format(baseFormat,
oauth_consumer_key,
oauth_nonce,
oauth_signature_method,
oauth_timestamp,
oauth_token,
oauth_version,
id);
baseString = string.Concat("GET&", Uri.EscapeDataString(resource_url), "&", Uri.EscapeDataString(baseString));
var compositeKey = string.Concat(Uri.EscapeDataString(oauth_consumer_secret),
"&", Uri.EscapeDataString(oauth_token_secret));
string oauth_signature;
using (HMACSHA1 hasher = new HMACSHA1(ASCIIEncoding.ASCII.GetBytes(compositeKey)))
{
oauth_signature = Convert.ToBase64String(
hasher.ComputeHash(ASCIIEncoding.ASCII.GetBytes(baseString)));
}
// create the request header
var headerFormat = "OAuth oauth_nonce=\"{0}\", oauth_signature_method=\"{1}\", " +
"oauth_timestamp=\"{2}\", oauth_consumer_key=\"{3}\", " +
"oauth_token=\"{4}\", oauth_signature=\"{5}\", " +
"oauth_version=\"{6}\"";
var authHeader = string.Format(headerFormat,
Uri.EscapeDataString(oauth_nonce),
Uri.EscapeDataString(oauth_signature_method),
Uri.EscapeDataString(oauth_timestamp),
Uri.EscapeDataString(oauth_consumer_key),
Uri.EscapeDataString(oauth_token),
Uri.EscapeDataString(oauth_signature),
Uri.EscapeDataString(oauth_version)
);
// make the request
ServicePointManager.Expect100Continue = false;
//var postBody = "screen_name=" + Uri.EscapeDataString(screen_name);
//var postBody = "q=" + Uri.EscapeDataString(query);
var postBody = "id=" + Uri.EscapeDataString(id);
// resource_url += "?" + postBody;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(resource_url);
request.Headers.Add("Authorization", authHeader);
request.Method = "GET";
request.ContentType = "application/x-www-form-urlencoded";
WebResponse response = request.GetResponse();
string responseData = new StreamReader(response.GetResponseStream()).ReadToEnd();
Console.ReadLine();

"Syntax error: expecting rightparen before not." <- I looked around, but I can't explain why this appears

The code for this will be a bit of a large dump, as it's part of a large project, but I simply can't find an explanation or solution for this problem. I'm coding in Java using Stencylworks, and I'm still new to this, so I'm just going to dump the code for the entire class, as I don't really know what might be causing it. (Yes, I will tag the lines the error message refers to within the code)
I would post the error message here, but the system here seems to think that it's code, so I'll just say that the errors are all the quoted message in the title, and that I've tagged the lines that the error message referred to within the posted code below.
And this is the code
package scripts
{
import flash.display.BlendMode;
import flash.events.*;
import flash.net.*;
import flash.filters.*;
import Box2DAS.Collision.*;
import Box2DAS.Collision.Shapes.*;
import Box2DAS.Common.*;
import Box2DAS.Dynamics.*;
import Box2DAS.Dynamics.Contacts.*;
import Box2DAS.Dynamics.Joints.*;
import stencyl.api.data.*;
import stencyl.api.engine.*;
import stencyl.api.engine.actor.*;
import stencyl.api.engine.behavior.*;
import stencyl.api.engine.bg.*;
import stencyl.api.engine.font.*;
import stencyl.api.engine.scene.*;
import stencyl.api.engine.sound.*;
import stencyl.api.engine.tile.*;
import stencyl.api.engine.utils.*;
import org.flixel.*;
import mochi.as3.*;
import flash.ui.Mouse;
public dynamic class Design_51_51_Spawn extends SceneScript
{
public var _PreviousScene1:String;
public var _PreviousScene2:String;
public var _PreviousScene3:String;
public var _PreviousScene4:String;
public var _PreviousScene5:String;
public var _XPositiona:Number;
public var _Ypositiona:Number;
public var _XPositionb:Number;
public var _YPositionb:Number;
public var _Xpositionc:Number;
public var _Ypositionc:Number;
public var _Ypositiond:Number;
public var _Xpositione:Number;
public var _Ypositione:Number;
public var _Xpositiond:Number;
public var _ChangeTrack1:Boolean;
public var _NextTrack:SoundClip;
public var _ChangeTrack2:Boolean;
public var _PreviousScene6:String;
public var _Xpositionf:Number;
public var _Ypositionf:Number;
public var _PreviousScene7:String;
public var _Xpositiong:Number;
public var _Ypositiong:Number;
public var _SpawnLocationa:String;
public var _SpawnLocationB:String;
public var _SpawnLocationc:String;
public var _SpawnLocationd:String;
public var _SpawnLocatione:String;
public var _SpawnLocationf:String;
public var _SpawnLocationg:String;
public var _Playeractor:Actor;
public var _NextScene:Scene;
public var _FadeOutTime:Number;
public var _FadeInTime:Number;
public var _NextSceneName1:String;
public var _Wind1:Number;
public var _Region:Region;
public var _NextScene2:Scene;
public var _NextSceneName2:String;
public var _Wind2:Number;
public var _Region2:Region;
public var _NextScene3:Scene;
public var _NextSceneName3:String;
public var _Wind3:Number;
public var _region3:Region;
public var _NextScene4:Scene;
public var _NextSceneName4:String;
public var _Wind4:Number;
public var _Region4:Region;
public var _NextScene5:Scene;
public var _NextSceneName5:String;
public var _Wind5:Number;
public var _Region5:Region;
override public function init():void
{
setGameAttribute("Respawn", false);
setVolumeForChannel(Number((getGameAttribute("wind"))) /100, 3);
if (sameAs((getGameAttribute("Previous Scene")), _PreviousScene1))
{
if ((getGameAttribute("Returned to beginning")as Boolean))
{
createActor(getActorType(328), (_XPositiona + Number("" + ((getGameAttribute(_SpawnLocationa)) as Array)[0])), (_Ypositiona + Number("" + ((getGameAttribute(_SpawnLocationa)) as Array)[1])), FRONT);
}
else
{
if ((getGameAttribute("33 saved")as Boolean))
{
createActor(getActorType(355), (_XPositiona + Number("" + ((getGameAttribute(_SpawnLocationa)) as Array)[0])), (_Ypositiona + Number("" + ((getGameAttribute(_SpawnLocationa)) as Array)[1])), FRONT);
}
else
{
createActor(getActorType(164), _XPositiona, _Ypositiona, FRONT);
}
}
if (_ChangeTrack1)
{
stopSoundOnChannel(1);
loopSoundOnChannel(_NextTrack, 1);
}
}
if (sameAs((getGameAttribute("Previous Scene")), _PreviousScene2))
{
if ((getGameAttribute("Returned to beginning")as Boolean))
{
createActor(getActorType(328), (_XPositionb + Number("" + ((getGameAttribute(_SpawnLocationB)) as Array)[0])), (_YPositionb + Number("" + ((getGameAttribute(_SpawnLocationB)) as Array)[1])), FRONT);
}
else
{
if ((getGameAttribute("33 saved")as Boolean))
{
createActor(getActorType(355), (_XPositionb + Number("" + ((getGameAttribute(_SpawnLocationB)) as Array)[0])), (_YPositionb + Number("" + ((getGameAttribute(_SpawnLocationB)) as Array)[1])), FRONT);
}
else
{
createActor(getActorType(164), _XPositionb, _YPositionb, FRONT);
}
}
if (_ChangeTrack2)
{
stopSoundOnChannel(1);
loopSoundOnChannel(_NextTrack, 1);
}
}
if (sameAs((getGameAttribute("Previous Scene")), _PreviousScene3))
{
if ((getGameAttribute("Returned to beginning")as Boolean))
{
createActor(getActorType(328), (_Xpositionc + Number("" + ((getGameAttribute(_SpawnLocationc)) as Array)[0])), (_Ypositionc + Number("" + ((getGameAttribute(_SpawnLocationc)) as Array)[1])), FRONT);
}
else
{
if ((getGameAttribute("33 saved")as Boolean))
{
createActor(getActorType(355), (_Xpositionc + Number("" + ((getGameAttribute(_SpawnLocationc)) as Array)[0])), (_Ypositionc + Number("" + ((getGameAttribute(_SpawnLocationc)) as Array)[1])), FRONT);
}
else
{
createActor(getActorType(164), _Xpositionc, _Ypositionc, FRONT);
}
}
}
if (sameAs((getGameAttribute("Previous Scene")), _PreviousScene4))
{
if ((getGameAttribute("Returned to beginning")as Boolean))
{
createActor(getActorType(328), (_Xpositiond + Number("" + ((getGameAttribute(_SpawnLocationd)) as Array)[0])), (_Ypositiond + Number("" + ((getGameAttribute(_SpawnLocationd)) as Array)[1])), FRONT);
}
else
{
if ((getGameAttribute("33 saved")as Boolean))
{
createActor(getActorType(355), (_Xpositiond + Number("" + ((getGameAttribute(_SpawnLocationd)) as Array)[0])), (_Ypositiond + Number("" + ((getGameAttribute(_SpawnLocationd)) as Array)[1])), FRONT);
}
else
{
createActor(getActorType(164), _Xpositiond, _Ypositiond, FRONT);
}
}
}
if (sameAs((getGameAttribute("Previous Scene")), _PreviousScene5))
{
if ((getGameAttribute("Returned to beginning")as Boolean))
{
createActor(getActorType(328), (_Xpositione + Number("" + ((getGameAttribute(_SpawnLocatione)) as Array)[0])), (_Ypositione + Number("" + ((getGameAttribute(_SpawnLocatione)) as Array)[1])), FRONT);
}
else
{
if ((getGameAttribute("33 saved")as Boolean))
{
createActor(getActorType(355), (_Xpositione + Number("" + ((getGameAttribute(_SpawnLocatione)) as Array)[0])), (_Ypositione + Number("" + ((getGameAttribute(_SpawnLocatione)) as Array)[1])), FRONT);
}
else
{
createActor(getActorType(164), _Xpositione, _Ypositione, FRONT);
}
}
}
if (sameAs((getGameAttribute("Previous Scene")), _PreviousScene6))
{
if ((getGameAttribute("Returned to beginning")as Boolean))
{
createActor(getActorType(328), (_Xpositionf + Number("" + ((getGameAttribute(_SpawnLocationf)) as Array)[0])), (_Ypositionf + Number("" + ((getGameAttribute(_SpawnLocationf)) as Array)[1])), FRONT);
}
else
{
if ((getGameAttribute("33 saved")as Boolean))
{
createActor(getActorType(355), (_Xpositionf + Number("" + ((getGameAttribute(_SpawnLocationf)) as Array)[0])), (_Ypositionf + Number("" + ((getGameAttribute(_SpawnLocationf)) as Array)[1])), FRONT);
}
else
{
createActor(getActorType(164), _Xpositionf, _Ypositionf, FRONT);
}
}
}
if (sameAs((getGameAttribute("Previous Scene")), _PreviousScene7))
{
if ((getGameAttribute("Returned to beginning")as Boolean))
{
createActor(getActorType(328), (_Xpositiong + Number("" + ((getGameAttribute(_SpawnLocationg)) as Array)[0])), (_Ypositiong + Number("" + ((getGameAttribute(_SpawnLocationg)) as Array)[1])), FRONT);
}
else
{
if ((getGameAttribute("33 saved")as Boolean))
{
createActor(getActorType(355), (_Xpositiong + Number("" + ((getGameAttribute(_SpawnLocationg)) as Array)[0])), (_Ypositiong + Number("" + ((getGameAttribute(_SpawnLocationg)) as Array)[1])), FRONT);
}
else
{
createActor(getActorType(164), _Xpositiong, _Ypositiong, FRONT);
}
}
}
setGameAttribute("Respawn", false);
setGameAttribute("Re/Spawning", false);
}
override public function update():void
{
if (!(_Playeractor ! = null)) // here
{
_Playeractor = getLastCreatedActor();
print("" + _Playeractor);
}
if (((_Region ! = null && _NextScene ! = null) && !(isTransitioning()))) // here
{
if (isInRegion(_Playeractor, _Region))
{
setGameAttribute("Re/Spawning", true);
switchScene(_NextScene.getID(), createFadeOut(((1000*_FadeOutTime))), createFadeIn(((1000*_FadeInTime))));
setGameAttribute("Previous Scene", _PreviousScene1);
setGameAttribute("Scene", _NextSceneName1);
setGameAttribute("wind", _Wind1);
setGameAttribute("Re/Spawning", false);
}
}
if (((_Region2 ! = null && _NextScene2 ! = null) && !(isTransitioning()))) // here
{
if (isInRegion(_Playeractor, _Region2))
{
setGameAttribute("Re/Spawning", true);
switchScene(_NextScene2.getID(), createFadeOut(((1000*_FadeOutTime))), createFadeIn(((1000*_FadeInTime))));
setGameAttribute("Previous Scene", _PreviousScene2);
setGameAttribute("Scene", _NextSceneName2);
setGameAttribute("wind", _Wind2);
setGameAttribute("Re/Spawning", false);
}
}
if (((_region3 ! = null && _NextScene3 ! = null) && !(isTransitioning()))) // here
{
if (isInRegion(_Playeractor, _region3))
{
setGameAttribute("Re/Spawning", true);
switchScene(_NextScene3.getID(), createFadeOut(((1000*_FadeOutTime))), createFadeIn(((1000*_FadeInTime))));
setGameAttribute("Previous Scene", _PreviousScene3);
setGameAttribute("Scene", _NextSceneName3);
setGameAttribute("wind", _Wind3);
setGameAttribute("Re/Spawning", false);
}
}
if (((_Region4 ! = null && _NextScene4 ! = null) && !(isTransitioning()))) // here
{
if (isInRegion(_Playeractor, _Region4))
{
setGameAttribute("Re/Spawning", true);
switchScene(_NextScene4.getID(), createFadeOut(((1000*_FadeOutTime))), createFadeIn(((1000*_FadeInTime))));
setGameAttribute("Previous Scene", _PreviousScene4);
setGameAttribute("Scene", _NextSceneName4);
setGameAttribute("wind", _Wind4);
setGameAttribute("Re/Spawning", false);
}
}
if (((_Region5 ! = null && _NextScene5 ! = null) && !(isTransitioning()))) // here
{
if (isInRegion(_Playeractor, _Region5))
{
setGameAttribute("Re/Spawning", true);
switchScene(_NextScene5.getID(), createFadeOut(((1000*_FadeOutTime))), createFadeIn(((1000*_FadeInTime))));
setGameAttribute("Previous Scene", _PreviousScene5);
setGameAttribute("Scene", _NextSceneName5);
setGameAttribute("wind", _Wind5);
setGameAttribute("Re/Spawning", false);
}
}
}
override public function draw(g:Graphics, x:Number, y:Number):void
{
}
public function Design_51_51_Spawn(ignore:*, scene:GameState)
{
super(scene);
nameMap["Previous Scene 1"] = "_PreviousScene1";
nameMap["Previous Scene 2"] = "_PreviousScene2";
nameMap["Previous Scene 3"] = "_PreviousScene3";
nameMap["Previous Scene 4"] = "_PreviousScene4";
nameMap["Previous Scene 5"] = "_PreviousScene5";
nameMap["X Position a"] = "_XPositiona";
nameMap["Y position a"] = "_Ypositiona";
nameMap["X Position b"] = "_XPositionb";
nameMap["Y Position b"] = "_YPositionb";
nameMap["X position c"] = "_Xpositionc";
nameMap["Y position c"] = "_Ypositionc";
nameMap["Y position d"] = "_Ypositiond";
nameMap["X position e"] = "_Xpositione";
nameMap["Y position e"] = "_Ypositione";
nameMap["X position d"] = "_Xpositiond";
nameMap["Change Track 1?"] = "_ChangeTrack1";
nameMap["Next Track"] = "_NextTrack";
nameMap["Change Track 2?"] = "_ChangeTrack2";
nameMap["Previous Scene 6"] = "_PreviousScene6";
nameMap["X position f"] = "_Xpositionf";
nameMap["Y position f"] = "_Ypositionf";
nameMap["Previous Scene 7"] = "_PreviousScene7";
nameMap["X position g"] = "_Xpositiong";
nameMap["Y position g"] = "_Ypositiong";
nameMap["Spawn Location a"] = "_SpawnLocationa";
nameMap["Spawn Location B"] = "_SpawnLocationB";
nameMap["Spawn Location c"] = "_SpawnLocationc";
nameMap["Spawn Location d"] = "_SpawnLocationd";
nameMap["Spawn Location e"] = "_SpawnLocatione";
nameMap["Spawn Location f"] = "_SpawnLocationf";
nameMap["Spawn Location g"] = "_SpawnLocationg";
nameMap["Player actor"] = "_Playeractor";
nameMap["Next Scene 1"] = "_NextScene";
nameMap["Fade Out Time"] = "_FadeOutTime";
nameMap["Fade In Time"] = "_FadeInTime";
nameMap["Next Scene Name 1"] = "_NextSceneName1";
nameMap["Wind 1"] = "_Wind1";
nameMap["Region 1"] = "_Region";
nameMap["Next Scene 2"] = "_NextScene2";
nameMap["Next Scene Name 2"] = "_NextSceneName2";
nameMap["Wind 2"] = "_Wind2";
nameMap["Region 2"] = "_Region2";
nameMap["Next Scene 3"] = "_NextScene3";
nameMap["Next Scene Name 3"] = "_NextSceneName3";
nameMap["Wind 3"] = "_Wind3";
nameMap["region 3"] = "_region3";
nameMap["Next Scene 4"] = "_NextScene4";
nameMap["Next Scene Name 4"] = "_NextSceneName4";
nameMap["Wind 4"] = "_Wind4";
nameMap["Region 4"] = "_Region4";
nameMap["Next Scene 5"] = "_NextScene5";
nameMap["Next Scene Name 5"] = "_NextSceneName5";
nameMap["Wind 5"] = "_Wind5";
nameMap["Region 5"] = "_Region5";
}
override public function forwardMessage(msg:String):void
{
}
}
}
Thank you for your time!
It appears that your issue is happening because you have a space between "!" and "=" on all of the lines that you tagged. You're attempting to use the inequality operator, which is "!=", or an exclamation mark followed by an equals sign with no space.
When you have the exclamation mark by itself, it is interpreted as a "logical not" and the error message that you're getting is because the compiler is trying to make its best guess at what you're trying to do.
If you remove all of the spaces between "!" and "=" then this error should be taken care of.

Bukkit NullPointerException onEnable()

I've been working on a new plugin, and when I load it up, it gives me a "NullPointerException" error, and I can't seem to find where it could find an error. Here is the error:
[20:15:45] [Server thread/INFO]: [EntityManager] Enabling EntityManager v3.0.0.4
[20:15:45] [Server thread/INFO]: [0;31;1mEntityManager [0;32;1m3.0.0.4[0;36;1m Enabled![m
[20:15:45] [Server thread/ERROR]: Error occurred while enabling EntityManager v3.0.0.4 (Is it up to date?)
java.lang.NullPointerException
at me.AngryCupcake274.EntityManager.EntityManager.loadConfiguration(EntityManager.java:296) ~[?:?]
at me.AngryCupcake274.EntityManager.EntityManager.onEnable(EntityManager.java:63) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:316) ~[spigot.jar:git-Spigot-1649]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:332) [spigot.jar:git-Spigot-1649]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:417) [spigot.jar:git-Spigot-1649]
at org.bukkit.craftbukkit.v1_7_R4.CraftServer.loadPlugin(CraftServer.java:476) [spigot.jar:git-Spigot-1649]
at org.bukkit.craftbukkit.v1_7_R4.CraftServer.enablePlugins(CraftServer.java:394) [spigot.jar:git-Spigot-1649]
at net.minecraft.server.v1_7_R4.MinecraftServer.n(MinecraftServer.java:360) [spigot.jar:git-Spigot-1649]
at net.minecraft.server.v1_7_R4.MinecraftServer.g(MinecraftServer.java:334) [spigot.jar:git-Spigot-1649]
at net.minecraft.server.v1_7_R4.MinecraftServer.a(MinecraftServer.java:290) [spigot.jar:git-Spigot-1649]
at net.minecraft.server.v1_7_R4.DedicatedServer.init(DedicatedServer.java:210) [spigot.jar:git-Spigot-1649]
at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:458) [spigot.jar:git-Spigot-1649]
at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [spigot.jar:git-Spigot-1649]
package me.AngryCupcake274.EntityManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.*;
import org.bukkit.event.Listener;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;
public class EntityManager extends JavaPlugin implements Listener {
RemoveEntities reme;
CommandHandler comh;
CleanEntities cent;
int loopdelay;
String oneminutemessage;
String oneminutecolor;
String threesecondsmessage;
String threesecondscolor;
String twosecondsmessage;
String twosecondscolor;
String onesecondmessage;
String onesecondcolor;
String finalmessage;
String finalcolor;
String oneMinWarn;
String threeSecWarn;
String twoSecWarn;
String oneSecWarn;
String removeInfo;
String[] worldNames;
Server server = Bukkit.getServer();
ConsoleCommandSender console = server.getConsoleSender();
PluginDescriptionFile pdf = this.getDescription();
String pdfEnable = ChatColor.RED + pdf.getName() + " " + ChatColor.GREEN
+ pdf.getVersion() + ChatColor.AQUA + " Enabled!";
String pdfDisable = ChatColor.RED + pdf.getName() + " " + ChatColor.GREEN
+ pdf.getVersion() + ChatColor.DARK_PURPLE + " Enabled!";
Player cleaner;
int counter = 0;
int totalcounter = 0;
#Override
public void onEnable() {
console.sendMessage(pdfEnable);
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
saveDefaultConfig();
loadConfiguration();
scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
#Override
public void run() {
for (int first = 0; first >= 1; first++) {
cleanUp();
}
}
}, 0L, 12000L);
}
#Override
public void onDisable() {
console.sendMessage(pdfDisable);
}
#SuppressWarnings("deprecation")
public void cleanUp() {
// warn
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(oneMinWarn);
}
console.sendMessage(oneMinWarn);
BukkitScheduler warn3 = Bukkit.getServer().getScheduler();
warn3.scheduleSyncDelayedTask(this, new Runnable() {
#Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(threeSecWarn);
}
console.sendMessage(threeSecWarn);
}
}, 1220L);
BukkitScheduler warn2 = Bukkit.getServer().getScheduler();
warn2.scheduleSyncDelayedTask(this, new Runnable() {
#Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(twoSecWarn);
}
console.sendMessage(twoSecWarn);
}
}, 1240L);
BukkitScheduler warn1 = Bukkit.getServer().getScheduler();
warn1.scheduleSyncDelayedTask(this, new Runnable() {
#Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(oneSecWarn);
}
console.sendMessage(oneSecWarn);
}
}, 1260L);
BukkitScheduler doAction = Bukkit.getServer().getScheduler();
doAction.scheduleSyncDelayedTask(this, new Runnable() {
#Override
public void run() {
reme.removeEntities();
}
}, 1280L);
}
#SuppressWarnings("deprecation")
public void cleanUpCommand() {
// warn
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(threeSecWarn);
}
console.sendMessage(threeSecWarn);
BukkitScheduler warn2c = Bukkit.getServer().getScheduler();
warn2c.scheduleSyncDelayedTask(this, new Runnable() {
#Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(twoSecWarn);
}
console.sendMessage(twoSecWarn);
}
}, 20L);
BukkitScheduler warn1c = Bukkit.getServer().getScheduler();
warn1c.scheduleSyncDelayedTask(this, new Runnable() {
#Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(oneSecWarn);
}
console.sendMessage(oneSecWarn);
}
}, 40L);
BukkitScheduler doAction = Bukkit.getServer().getScheduler();
doAction.scheduleSyncDelayedTask(this, new Runnable() {
#Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(removeInfo);
}
console.sendMessage(removeInfo);
}
}, 60L);
}
public void cleanUpCommand2() {
BukkitScheduler doAction = Bukkit.getServer().getScheduler();
doAction.scheduleSyncDelayedTask(this, new Runnable() {
#Override
public void run() {
reme.removeEntities();
}
}, 0L);
}
public void loadConfiguration() {
String ltime = "looptime";
String onemmsg = "oneminute.message";
String onemcolor = "oneminute.color";
String threesmsg = "threeseconds.message";
String threescolor = "threeseconds.color";
String twosmsg = "twoseconds.message";
String twoscolor = "twoseconds.color";
String onesmsg = "onesecond.message";
String onescolor = "onesecond.color";
String fmsg = "final.message";
String fcolor = "final.color";
String arrowr = "arrow";
String boatr = "boat";
String itemr = "dropped_item";
String eggr = "egg";
String enderdragonr = "ender_dragon";
String enderpearlr = "ender_pearl";
String endersignalr = "ender_signal";
String xporbr = "experience_orb";
String fireballr = "fireball";
String fireworkr = "firework";
String fishinghookr = "fishing_hook";
String itemframer = "item_frame";
String leashr = "leash_hitch";
String lightningr = "lightning";
String minecartr = "minecart";
String minecartchestr = "minecart_chest";
String minecartcommandr = "minecart_command";
String minecartfurnacer = "minecart_furnace";
String minecarthopperr = "minecart_hopper";
String minecartmobspawnerr = "minecart_mob_spawner";
String minecarttntr = "minecart_tnt";
String paintingr = "painting";
String primedtntr = "primed_tnt";
String sfireballr = "small_fireball";
String snowballr = "snowball";
String splashpotionr = "splash_potion";
String expbottler = "exp_bottle";
String thrownxpbottler = "thrown_exp_bottle";
String witherskullr = "wither_skull";
getConfig().addDefault(ltime, (10 * 60 * 20));
getConfig().addDefault(onemmsg,
"Ground items will be removed in 1 minute!");
getConfig().addDefault(onemcolor, "AQUA");
getConfig().addDefault(threesmsg,
"Ground items will be removed in 3 seconds!");
getConfig().addDefault(threescolor, "DARK_GREEN");
getConfig().addDefault(twosmsg, "2 seconds!");
getConfig().addDefault(twoscolor, "GOLD");
getConfig().addDefault(onesmsg, "1 second!");
getConfig().addDefault(onescolor, "RED");
getConfig().addDefault(fmsg, "Ground items will be removed!");
getConfig().addDefault(fcolor, "DARK_RED");
getConfig().addDefault(arrowr, true);
getConfig().addDefault(boatr, false);
getConfig().addDefault(itemr, true);
getConfig().addDefault(eggr, true);
getConfig().addDefault(enderdragonr, false);
getConfig().addDefault(enderpearlr, true);
getConfig().addDefault(endersignalr, true);
getConfig().addDefault(xporbr, true);
getConfig().addDefault(fireballr, true);
getConfig().addDefault(fireworkr, true);
getConfig().addDefault(fishinghookr, false);
getConfig().addDefault(itemframer, false);
getConfig().addDefault(leashr, false);
getConfig().addDefault(lightningr, true);
getConfig().addDefault(minecartr, false);
getConfig().addDefault(minecartchestr, false);
getConfig().addDefault(minecartcommandr, false);
getConfig().addDefault(minecartfurnacer, false);
getConfig().addDefault(minecarthopperr, false);
getConfig().addDefault(minecartmobspawnerr, false);
getConfig().addDefault(minecarttntr, false);
getConfig().addDefault(paintingr, false);
getConfig().addDefault(primedtntr, true);
getConfig().addDefault(sfireballr, true);
getConfig().addDefault(snowballr, true);
getConfig().addDefault(splashpotionr, true);
getConfig().addDefault(expbottler, true);
getConfig().addDefault(thrownxpbottler, true);
getConfig().addDefault(witherskullr, true);
getConfig().options().copyDefaults(true);
saveConfig();
loopdelay = getConfig().getInt("looptime");
oneminutemessage = getConfig().getString("oneminute.message");
oneminutecolor = getConfig().getString("oneminute.color");
threesecondsmessage = getConfig().getString("threeseconds.message");
threesecondscolor = getConfig().getString("threeseconds.color");
twosecondsmessage = getConfig().getString("twoseconds.message");
twosecondscolor = getConfig().getString("twoseconds.color");
onesecondmessage = getConfig().getString("onesecond.message");
onesecondcolor = getConfig().getString("onesecond.color");
finalmessage = getConfig().getString("final.message");
finalcolor = getConfig().getString("final.color");
oneMinWarn = ChatColor.valueOf(oneminutecolor) + oneminutemessage;
threeSecWarn = ChatColor.valueOf(threesecondscolor)
+ threesecondsmessage;
twoSecWarn = ChatColor.valueOf(twosecondscolor) + twosecondsmessage;
oneSecWarn = ChatColor.valueOf(onesecondcolor) + onesecondmessage;
removeInfo = ChatColor.valueOf(finalcolor) + finalmessage;
reme.arrow = getConfig().getBoolean("arrow");
reme.boat = getConfig().getBoolean("boat");
reme.droppeditem = getConfig().getBoolean("dropped_item");
reme.egg = getConfig().getBoolean("egg");
reme.enderpearl = getConfig().getBoolean("ender_pearl");
reme.endersignal = getConfig().getBoolean("ender_signal");
reme.experienceorb = getConfig().getBoolean("experience_orb");
reme.fireball = getConfig().getBoolean("fireball");
reme.firework = getConfig().getBoolean("firework");
reme.fishinghook = getConfig().getBoolean("fishing_hook");
reme.itemframe = getConfig().getBoolean("item_frame");
reme.leashhitch = getConfig().getBoolean("leash_hitch");
reme.lightning = getConfig().getBoolean("lightning");
reme.minecart = getConfig().getBoolean("minecart");
reme.minecartchest = getConfig().getBoolean("minecart_chest");
reme.minecartcommand = getConfig().getBoolean("minecart_command");
reme.minecartfurnace = getConfig().getBoolean("minecart_furnace");
reme.minecarthopper = getConfig().getBoolean("minecart_hopper");
reme.minecartmobspawner = getConfig().getBoolean("minecart_mob_spawner");
reme.minecarttnt = getConfig().getBoolean("minecart_tnt");
reme.painting = getConfig().getBoolean("painting");
reme.primedtnt = getConfig().getBoolean("primed_tnt");
reme.smallfireball = getConfig().getBoolean("small_fireball");
reme.snowball = getConfig().getBoolean("snowball");
reme.splashpotion = getConfig().getBoolean("splash_potion");
reme.thrownexpbottle = getConfig().getBoolean("exp_bottle");
reme.witherskull = getConfig().getBoolean("wither_skull");
saveDefaultConfig();
}
public void reloadPlugin() {
reloadConfig();
loopdelay = getConfig().getInt("looptime");
oneminutemessage = getConfig().getString("oneminute.message");
oneminutecolor = getConfig().getString("oneminute.color");
threesecondsmessage = getConfig().getString("threeseconds.message");
threesecondscolor = getConfig().getString("threeseconds.color");
twosecondsmessage = getConfig().getString("twoseconds.message");
twosecondscolor = getConfig().getString("twoseconds.color");
onesecondmessage = getConfig().getString("onesecond.message");
onesecondcolor = getConfig().getString("onesecond.color");
finalmessage = getConfig().getString("final.message");
finalcolor = getConfig().getString("final.color");
reme.arrow = getConfig().getBoolean("arrow");
reme.boat = getConfig().getBoolean("boat");
reme.droppeditem = getConfig().getBoolean("dropped_item");
reme.egg = getConfig().getBoolean("egg");
reme.enderpearl = getConfig().getBoolean("ender_pearl");
reme.endersignal = getConfig().getBoolean("ender_signal");
reme.experienceorb = getConfig().getBoolean("experience_orb");
reme.fireball = getConfig().getBoolean("fireball");
reme.firework = getConfig().getBoolean("firework");
reme.fishinghook = getConfig().getBoolean("fishing_hook");
reme.itemframe = getConfig().getBoolean("item_frame");
reme.leashhitch = getConfig().getBoolean("leash_hitch");
reme.lightning = getConfig().getBoolean("lightning");
reme.minecart = getConfig().getBoolean("minecart");
reme.minecartchest = getConfig().getBoolean("minecart_chest");
reme.minecartcommand = getConfig().getBoolean("minecart_command");
reme.minecartfurnace = getConfig().getBoolean("minecart_furnace");
reme.minecarthopper = getConfig().getBoolean("minecart_hopper");
reme.minecartmobspawner = getConfig().getBoolean("minecart_mob_spawner");
reme.minecarttnt = getConfig().getBoolean("minecart_tnt");
reme.painting = getConfig().getBoolean("painting");
reme.primedtnt = getConfig().getBoolean("primed_tnt");
reme.smallfireball = getConfig().getBoolean("small_fireball");
reme.snowball = getConfig().getBoolean("snowball");
reme.splashpotion = getConfig().getBoolean("splash_potion");
reme.thrownexpbottle = getConfig().getBoolean("exp_bottle");
reme.witherskull = getConfig().getBoolean("wither_skull");
getServer().getScheduler().cancelTasks(this);
getServer().getPluginManager().disablePlugin(this);
getServer().getPluginManager().enablePlugin(this);
}
}
me.AngryCupcake274.EntityManager.EntityManager.loadConfiguration(EntityManager.java:296)
The exception is thrown at line 296 of your EntityManager.java file.
reme.arrow = getConfig().getBoolean("arrow");
At this point of time reme is still null and therefore you can't assign arrow.
You should ensure that RemoveEntitites is already instantiated once you call loadConfiguration() in your onEnable() method.
Also see What is a NPE and how do I fix it?.
I did it!
Instead of setting the RemoveEntities variables, I told the RemoveEntities class to find the variables in the EntityManager class.

.ToList() throws exception of "Object reference not set to an instance of an object."

private void BindDataGridDetails(string p)
{
var allClients = new List<DataLayer.Client>();
if (string.IsNullOrWhiteSpace(p))
{
allClients = entities.Clients.ToList();
}
else
{
allClients = entities.Clients.Where(m =>m.CompanyName.Contains(p)||m.ContactPersonName.Contains(p)).ToList();
}
allClients = entities.Clients.ToList();
var finalClientList = allClients.Select(v => new
{
v.UserId,
v.MobileNumber,
v.Designation,
v.CompanyName,
v.ContactPersonName,
EmailAddress = v.User.EmailAddress,
status = v.User.Status.Name
}).ToList();
Gdview.DataSource = finalClientList;
Gdview.DataBind();
}
Following is the required db table
User(id,statusid,emailaddress)
client(id,userid,designation,mobilenumber,companyname,contactperson)
status(statusid,statusname)

writing posixAccount to LDAP doesn't work

I tried to write PosixAccount on LDAP to an existing user. i get no error, but when checking LDAP the new entry has not been written.
i added a new user first which is working well!
=>
public bool RegisterUser(UserObject userObj, HttpContext httpContext){
bool success = false;
//create a directory entry
using (DirectoryEntry de = new DirectoryEntry())
{
try
{
InitializeCommonDataForDirectoryEntry(
de,
String.Format("{0}/{1}",
GetConfigEntry(Common.CommonDefinitions.CE_LDAP_CONFIG_SERVER, httpContext),
GetConfigEntry(Common.CommonDefinitions.CE_LDAP_CONFIG_DIRECTORY_ENTRY_ROOT, httpContext)),
httpContext);
DirectorySearcher ds = new DirectorySearcher(de);
ds.SearchScope = System.DirectoryServices.SearchScope.Subtree;
ds.Filter = "(&(objectClass=organizationalUnit)(ou=people))";
SearchResult result = ds.FindOne();
if (result != null)
{
DirectoryEntry myDirectoryEntry = result.GetDirectoryEntry();
DirectoryEntry newEntry = myDirectoryEntry.Children.Add(String.Format("cn={0}", userObj.userName), "inetOrgPerson");
if (userObj.company != null && !userObj.company.Equals(String.Empty))
newEntry.Properties["businessCategory"].Add(String.Format("{0}", userObj.company));
newEntry.Properties["givenName"].Add(String.Format("{0}", userObj.firstName));
newEntry.Properties["sn"].Add(String.Format("{0}", userObj.lastName));
newEntry.Properties["uid"].Add(String.Format("{0}", userObj.userName));
newEntry.Properties["mail"].Add(String.Format("{0}", userObj.email));
userObj.password = GenerateSaltedSHA1(userObj.password);
newEntry.Properties["userPassword"].Add(String.Format("{0}", userObj.password));
newEntry.Properties["pager"].Add(String.Format("{0}", userObj.newsletter));
newEntry.Properties["initials"].Add(String.Format("{0}", GetConfigEntry(Common.CommonDefinitions.CE_MOWEE_PACKAGE_1, httpContext)));
newEntry.CommitChanges();
newEntry.RefreshCache();
success = true;
}
}
catch (Exception ex)
{
Trace.Write("Exception : RegisterUser: " + ex);
GeneralUtils.SendBugMail(ex, httpContext);
}
}
return success;
}
after that i want to write posixAccount for that user, which is not working
maybe someone can help me PLEASE and check what i did wrong !?
=>
public bool WritePosixAccountDataForRegisteredUser(UserObject userObj, HttpContext httpContext)
{
bool success = false;
//create a directory entry
using (DirectoryEntry de = new DirectoryEntry())
{
try
{
InitializeCommonDataForDirectoryEntry(
de,
String.Format("{0}/ou=people,{1}",
GetConfigEntry(Common.CommonDefinitions.CE_LDAP_CONFIG_SERVER, httpContext),
GetConfigEntry(Common.CommonDefinitions.CE_LDAP_CONFIG_DIRECTORY_ENTRY_ROOT, httpContext)),
httpContext);
DirectorySearcher ds = new DirectorySearcher(de);
ds.SearchScope = System.DirectoryServices.SearchScope.Subtree;
ds.Filter = String.Format("(&(objectClass=*)(cn={0}))", userObj.userName);
SearchResult result = ds.FindOne();
if (result != null)
{
DirectoryEntry userEntry = result.GetDirectoryEntry();
//mandatory attributes
/*
* cn
gidNumber
homeDirectory
uid
uidNumber
* */
IADsPropertyList propList = (IADsPropertyList)userEntry.NativeObject;
ActiveDs.PropertyEntry myNewEntry1 = new ActiveDs.PropertyEntry();
ActiveDs.IADsPropertyValue propVal1 = new ActiveDs.PropertyValue();
propVal1.CaseIgnoreString = "posixAccount";
propVal1.ADsType = (int)ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING;
myNewEntry1.Name = "objectClass";
myNewEntry1.Values = new object[] { propVal1 };
myNewEntry1.ControlCode = (int)ADS_PROPERTY_OPERATION_ENUM.ADS_PROPERTY_APPEND;
myNewEntry1.ADsType = (int)ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING;
propList.PutPropertyItem(myNewEntry1);
ActiveDs.PropertyEntry myNewEntry2 = new ActiveDs.PropertyEntry();
ActiveDs.IADsPropertyValue propVal2 = new ActiveDs.PropertyValue();
propVal2.CaseIgnoreString = "504";
propVal2.ADsType = (int)ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING;
myNewEntry2.Name = "gidNumber";
myNewEntry2.Values = new object[] { propVal2 };
myNewEntry2.ControlCode = (int)ADS_PROPERTY_OPERATION_ENUM.ADS_PROPERTY_APPEND;
myNewEntry2.ADsType = (int)ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING;
propList.PutPropertyItem(myNewEntry2);
ActiveDs.PropertyEntry myNewEntry3 = new ActiveDs.PropertyEntry();
ActiveDs.IADsPropertyValue propVal3 = new ActiveDs.PropertyValue();
propVal3.CaseIgnoreString = "/data/WowzaMediaServer-3.0.3/content/mowee/" + userObj.userName;
propVal3.ADsType = (int)ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING;
myNewEntry3.Name = "homeDirectory";
myNewEntry3.Values = new object[] { propVal3 };
myNewEntry3.ControlCode = (int)ADS_PROPERTY_OPERATION_ENUM.ADS_PROPERTY_APPEND;
myNewEntry3.ADsType = (int)ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING;
propList.PutPropertyItem(myNewEntry3);
ActiveDs.PropertyEntry myNewEntry4 = new ActiveDs.PropertyEntry();
ActiveDs.IADsPropertyValue propVal4 = new ActiveDs.PropertyValue();
propVal4.CaseIgnoreString = "1100";
propVal4.ADsType = (int)ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING;
myNewEntry4.Name = "uidNumber";
myNewEntry4.Values = new object[] { propVal4 };
myNewEntry4.ControlCode = (int)ADS_PROPERTY_OPERATION_ENUM.ADS_PROPERTY_APPEND;
myNewEntry4.ADsType = (int)ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING;
propList.PutPropertyItem(myNewEntry4);
ActiveDs.PropertyEntry myNewEntry5 = new ActiveDs.PropertyEntry();
ActiveDs.IADsPropertyValue propVal5 = new ActiveDs.PropertyValue();
propVal5.CaseIgnoreString = userObj.userName;
propVal5.ADsType = (int)ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING;
myNewEntry5.Name = "cn";
myNewEntry5.Values = new object[] { propVal5 };
myNewEntry5.ControlCode = (int)ADS_PROPERTY_OPERATION_ENUM.ADS_PROPERTY_APPEND;
myNewEntry5.ADsType = (int)ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING;
propList.PutPropertyItem(myNewEntry5);
ActiveDs.PropertyEntry myNewEntry6 = new ActiveDs.PropertyEntry();
ActiveDs.IADsPropertyValue propVal6 = new ActiveDs.PropertyValue();
propVal6.CaseIgnoreString = userObj.userName;
propVal6.ADsType = (int)ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING;
myNewEntry6.Name = "uid";
myNewEntry6.Values = new object[] { propVal6 };
myNewEntry6.ControlCode = (int)ADS_PROPERTY_OPERATION_ENUM.ADS_PROPERTY_APPEND;
myNewEntry6.ADsType = (int)ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING;
propList.PutPropertyItem(myNewEntry6);
de.RefreshCache(new String[] { "objectClass" });
de.RefreshCache(new String[] { "gidNumber" });
de.RefreshCache(new String[] { "homeDirectory" });
de.RefreshCache(new String[] { "uidNumber" });
de.RefreshCache(new String[] { "cn" });
de.RefreshCache(new String[] { "uid" });
de.CommitChanges();
success = true;
}
}
catch (Exception ex)
{
Trace.Write("Exception : RegisterUser: " + ex);
GeneralUtils.SendBugMail(ex, httpContext);
}
}
return success;
}
I think the error you get would be informative for diagnosing any further.
When you create an object in AD I am pretty sure even if you do not specify a CN you get a default naming attribute of CN set. So this posixAccount create, which is setting cn, might be conflicting with an existing cn value. I forget if CN is multivalued or single valued in AD, but if it is single valued this would make more sense.