|
Hi
Im trying to retrieve user properties from active directory.
It successfully gets the first required property, but after that all i get is
'NullReferenceException - Object reference not set to an instance of an object'
Why is this? Here is the code:
DirectoryEntry standardUser = new DirectoryEntry("LDAP://CN=" + txtUser.Text.ToString() + ",OU=Users - Standard Users,DC=mydomain,DC=com,DC=uk", "username", "password");<br />
string sUSN = standardUser.Properties["userPrincipalName"].Value.ToString();<br />
string nastsprofile = (standardUser.Properties["TerminalServicesProfilePath"].Value.ToString());
The bit which gets the userPrincipalName works fine. After that it all goes wrong.
|
|
|
|
|
Well, tha fact that you can get the userPrincipalName means that standardUser is fine, so the problem must be that
standardUser.Properties["TerminalServicesProfilePath"].Value is null. I think you might need a lower case 'T' or something.
I found this similar problem on t'internet HERE[^], where the apparent solution was to use lower case.
My current favourite word is: Bacon!
-SK Genius
|
|
|
|
|
Ive followed the link.
And changed it to all lowercase.
And replaced .value with .invokeget.
Still no avail
|
|
|
|
|
OK, i think i have it. I'm quite sure you do need to use InvokeGet. InvokeGet will return an object, so you'll need to cast it as a string.
string nastsprofile = standardUser.InvokeGet("TerminalServicesProfileName") as string;
or
string nastsprofile = standardUser.InvokeGet("terminalServicesProfileName") as string;
or
string nastsprofile = standardUser.InvokeGet("terminalservicesprofilename") as string;
I'm pretty sure one of those should work.
My current favourite word is: Bacon!
-SK Genius
|
|
|
|
|
hello
wich function I can add to this function for having a conference (in voice not msg) between 3 personne at minimum
private void checkConf_CheckedChanged(object sender, EventArgs e)
{
int nBusyCount = 0;
for (int nLineCount = 0; nLineCount < 2; nLineCount++)
{
if (iaxc.OnLineState(nLineCount))
nBusyCount++;
}
if (nBusyCount < 2 && CheckStartConf.Checked)
{
CheckStartConf.Checked = false;
MessageBox.Show("Dial/receive more than one calls and then click start conference check box.");
}
}
|
|
|
|
|
Wow - what a question. How is your computer actually in control of your phone lines ? Looks like you have some sort of API, have you read it's docs ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
i'm develloping a softphone with the API AsteriskIaxClient (vb.net).
And i want to implemant a function Conference.
But sorry i don't understand you.
Please help me.
if someone have any idea about this probleme can we help me and thank you ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
OK, lets revisit this. You are using a third party API that most people here will not have heard of, in VB.NET. So, you're asking about it in our C# forum, and at first, not even telling us what you're using.
I suggest you read the article I link to in my sig, you obviously have trouble working out how to find the best resources for your problems. Your starting point is the docs for the library you're using, any support forums they may have, etc.
I have to admit that googling the API name gets me four pages, in French. I hope you have the resources to do better, because if the whole web has not heard of this library, odds are low that we will have.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
I'm working with this library AsteriskIaxClient and i wan't to develop a function of conference.
Please if you have an idea about this API help me to implemant this function on my project.
And thank you for your help.
|
|
|
|
|
I create a list view and add icons to all the listviewItems , i can see icon when they are list, and small but when i enable large icon there is only text shown not icon. How can i see icon plz help me out.
|
|
|
|
|
Are you providing large icons for the items ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I dont know how to create a trigger inside a stored procedure
|
|
|
|
|
What does this have to do with C# ?
A trigger and a stored proc are two different things, do you mean you want a stored proc to fire a trigger ? A trigger is fired on a specific action, such a deleting or adding a row. You can't make a trigger just fire from one proc, instead write a function or proc that your first proc calls.
Try asking in the SQL forum in future, when your question is about SQL, please. It really does help you get better answers.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I've been constructing an ASP.Net application using the 2.0framework,
I wanted to see if I can set up my pages for access directly via localhost
. My login page loads, and any validation controls on the page
work fine, so I know it's recognizing the ASP.Net code there, however,
when I try to log on, the page just refresh not go to next means
response.redirect can not work properly how can i solve this problem
,
|
|
|
|
|
Didnt quite get you, the header ssays you want to run ASP.NET on IIS and you are asking about running it locally..
As for running it on IIS, please specify the OS you are running..
is it a WIN XP or WIN Server 2003?
|
|
|
|
|
Member 4432086 wrote: I've been constructing an ASP.Net application using the 2.0framework,
WE have an ASP.NET forum.
Member 4432086 wrote: means
response.redirect can not work
no WAY does it mean that.
Member 4432086 wrote: how can i solve this problem
1 - ask in the right forum
2 - debug your application to see what's really going on
3 - post code if you want help, your code is obviously broken. Perhaps you changed the server and you used absolute URLs in code that are now invalid ? No WAY ASP.NET works but response.redirect is broken. Your code is broken.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
I added some files in my projects resources and made them as a embedded resources. I want to get all the file names.
Plz help...
thanx in advance...
|
|
|
|
|
Hi Guru,
Here is the code snipet:
System.Reflection.Assembly ass = System.Reflection.Assembly.GetExecutingAssembly();
string[] files = ass.GetManifestResourceNames();
for(int i=0;i<files.Length;i++)
MessageBox.Show(files[i]);
Thanks,
Gopal.S
|
|
|
|
|
Hi,
I'm sure most of us have seen movies where there is a computer wizz hacking away at a computer, as he does, there is a window on the screen that seems to be showing all of the compiling code.
I know this is for dramatic effect, but is there a way (using C#) to reflect the compiled code (or better, the non-compiled code) as it is run onto a label or something?
Cheers,
Mark.
|
|
|
|
|
You could use reflection, but as for showing the actual code being run, I doubt that. I mean, you'd have to write code that executes after every statement, and shows it.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
You can use .NET Profiling API to rewrite the IL code when it is about to JIT.
So you can add such statements with that..
but you have to know a bit or two about IL.
|
|
|
|
|
Good Day,
I am working in an encryption utility as a school project. I'm all done with the byte manipulations and stuffs and just need to write the data as a file. I have already conceptualized the File Structure and is coded as:
[StructLayout(LayoutKind.Sequential)]<br />
struct LockFile<br />
{<br />
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]<br />
public string MagicNumber;<br />
public Hashtable IncrementalMappingArray;<br />
}
I need to Serialize that structure using this function I found somewhere:
private static byte[] RawSerialize(object anything)<br />
{<br />
int rawsize = Marshal.SizeOf(anything);<br />
IntPtr buffer = Marshal.AllocHGlobal(rawsize);<br />
Marshal.StructureToPtr(anything, buffer, false);<br />
byte[] rawdatas = new byte[rawsize];<br />
Marshal.Copy(buffer, rawdatas, 0, rawsize);<br />
Marshal.FreeHGlobal(buffer);<br />
return rawdatas;<br />
}
Then I write it as file:
LockFile theLockFile = new LockFile();<br />
theLockFile.MagicNumber = "myLock";<br />
theLockFile.IncrementalMappingArray = IMA;<br />
<br />
byte[] LockFileStream = RawSerialize(theLockFile);<br />
<br />
MessageBox.Show(LockFileStream.Length.ToString());<br />
<br />
<br />
string Filename = Path.GetFileNameWithoutExtension(txtPath.Text);<br />
<br />
string LockFilePath = Path.GetDirectoryName(txtPath.Text);<br />
<br />
File.WriteAllBytes(LockFilePath + "\\" + Filename + ".flk", LockFileStream);
But it always write the same value with 4 bytes in it. But the IMA (Hashtables) contains a lot of key-value pair. (Like 5mb).
Do I need to convert the hashtable to a byte[] first?
Thanks!
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
|
|
|
|
|
I have a couple of questions.
1) What are you encrypting, and why a Hashtable?
2) Why did you choose a struct?
3) Have you checked the post-RawSerialize() byte arrays to verify sizes?
4) Are you using unmanaged code in your project?
And recommendations.
1) Go back on the Net and study up on the difference between ValueTypes and ReferenceTypes.
2) Use caution when you snag some code, you'll have to understand what's going on.
What I think is going on here is a boxing issue. You're using a struct to hold data, however your serialization routines are calling for Object. So, when you pass in your struct it is boxed, turning it into a reference type. Then you're calling Marshal.StructureToPtr passing in the boxed value. In essence you're serializing the address of your struct. That's why it's writing the 4 characters (8 bytes) to the file.
Scott P
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
carbon_golem wrote: What are you encrypting, and why a Hashtable?
Long Long Discussion.
carbon_golem wrote: 2) Why did you choose a struct?
Is there any other option?
carbon_golem wrote: 3) Have you checked the post-RawSerialize() byte arrays to verify sizes?
Yes, the output byte lenght is correct.
carbon_golem wrote: 4) Are you using unmanaged code in your project?
I'm not sure...
carbon_golem wrote: Go back on the Net and study up on the difference between ValueTypes and ReferenceTypes.
I'm sure I know the difference between the two.
carbon_golem wrote: Use caution when you snag some code, you'll have to understand what's going on.
I've already analyzed that piece of code and found out that I don't really need it.
So what I did is a simpler approach:
[Serializable]<br />
struct LockFile<br />
{<br />
public string MagicNumber;<br />
public Hashtable IncrementalMappingArray;<br />
}
<br />
private byte[] RawSerialize(object anything)<br />
{<br />
MemoryStream Stream = new MemoryStream();<br />
BinaryFormatter BF = new BinaryFormatter();<br />
BF.Serialize(Stream, anything);<br />
byte[] Data = Stream.ToArray();<br />
return Data;<br />
}<br />
<br />
private object RawDeserialize(byte[] byteStream)<br />
{<br />
MemoryStream Stream = new MemoryStream(byteStream);<br />
BinaryFormatter BF = new BinaryFormatter();<br />
object thisObject = BF.Deserialize(Stream);<br />
return thisObject;<br />
}
It is said that the most complex structures built by mankind are software systems. This is not generally appreciated because most people cannot see them. Maybe that's a good thing because if we saw them as buildings, we'd deem many of them unsafe.
|
|
|
|