Missing Properties in Active Directory's ResultPropertyCollection - c#

I have a ResultPropertyCollection object called resultValues.
I can view info about an AD user (eg their name) using this code:
resultValues["name"][0].ToString()
If I look up a user in Outlook's address book, I can see all the same info that I can see in C# as well as a photo of the user.
If Outlook is able to display the user's photo, why is it that resultValues["jpegPhoto"][0].ToString() and resultValues["photo"][0].ToString() throw System.ArgumentOutOfRangeException?
Wouldn't Outlook use the jpegPhoto attribute to retrieve the photo?

I worked it out, I need to use this attribute:
resultValues["thumbnailPhoto"][0];
However, why can't I find this attribute in the schema on MSDN?
(Answer found here: http://social.msdn.microsoft.com/Forums/vstudio/en-US/fc45bfd3-8a85-46cc-a687-95b99291ae1a/get-the-user-thumbnail-picture-from-active-directory?forum=csharpgeneral)

It's picture attribute, the attribute has Ldap-Display-Name thumbnailPhoto.
Take a look here http://msdn.microsoft.com/en-us/library/windows/desktop/ms680034(v=vs.85).aspx

Related

delete user from zk attendance device using c# api

I have set of ZK attendance device that using static IP address. I'm enrolling users to this machines using zkmkeeper.dll in C#. now i want to delete old users from these machines using system. I can't find the function to delete users, but there is function to disable. I want to delete that users permanently from devices.
I had a similar issue when deleting userInfo or enrolled data but i found a workaround
objCZKEM.DeleteEnrollData(machineId, userId, machineId, 12)
according to the documentation :
12 indicates deleting the user (including the fingerprints, card number and password).
#Yuuuucef, thank you for reference. According to documentation
5.2.4.3 DeleteEnrollData
VARIANT_BOOL DeleteEnrollData(LONG dwMachineNumber, LONG dwEnrollNumber,
LONG dwEMachineNumber, LONG dwBackupNumber)
The values of dwMachineNumber and dwEMachineNumber must be the same
After trying many ways I have finally found a way. clear all user data using axCZKEM1.ClearData(Convert.ToInt32(number), flag) and re enroll the data using Database.
The way I found works for me.
Use the SSR_deleteEnrollData function with only 3 parameters (while notice asks for 4 parameters)
SSR_deleteEnrolData(dwMachineNumber , dwEnrollNumber , dwBackupNumber)
Maybe depends of device version.

Cannot save content with an empty name on content save at controller level in Umbraco 8

I am getting this error on saving and Publish "Cannot save content with an empty name" at controller level in Umbraco 8
I have a simple method in surface controller after form submit, which has a file upload and name and email, but after save and publish, I get this error that "Cannot save content with an empty name"
IContentService contentService = Services.ContentService;
var content = contentService.CreateContent("samplename", udi, sample.ModelTypeAlias);
content.SetValue("entry", model.FileUpload);
contentService.SaveAndPublish(content);
Before this it worked fine in umbraco 7 for me.
Does it work when you give the node a name? I'm thinking that all Umbraco content (at least as a rule of thumb) needs a unique URL, which cannot be created if the node has no name. Might be a new sanity check for v8, but a good one as far as I see it.
CreateContent() only sets the Node name, but not the culture specific name of the content.
You will need to use SetCultureName(). This method sets the culture sepcific name, which is the empty name value that the error is complaining about on the SaveAndPublish()
IContentService contentService = Services.ContentService;
var content = contentService.CreateContent("samplename", udi, sample.ModelTypeAlias);
// You will need to set the culture specific name
content.SetCultureName("sampleName", culture)
content.SetValue("entry", model.FileUpload);
contentService.SaveAndPublish(content);
So for anyone facing the same issue, the answer i found was to set the culture if u have multi cultures enabled for your site
contentService.SaveAndPublish(content, "en-US");

Read Undelivered email body in C# windows form

I am developing one tool to keep track of emails and would like to trace the emails undelivered to sender.
I dont want to use any third party tool or any external reference
What I have tried?
-To read report Item but Body is in Chinese like language
-Googled on some solutions but nothing is working i.e. solution is related to
//PR_TRANSPORT_MESSAGE_HEADERS
link to get property name "http://schemas.microsoft.com/mapi/proptag/0x0C1A001F"
outlook PropertyAccessor class
PropName link is not working anymore.
Could anyone here please help me I would like to get from which sender the email delivery is failed.
Thank you in advance.
The PR_TRANSPORT_MESSAGE_HEADERS property contains the same Diagnostic information shown in the body. You just need to read it using the PropertyAccessor class and parse the string with From and To entries.
Outlook.PropertyAccessor oPA = reportItem.PropertyAccessor;
string transportHeaders = (string)oPA.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x007D001E");

WPF 4.0 SpellCheck issue loading Custom Dictionaries

Has anyone used a custom dictionary into WPF 4.0?
I am having an issue getting the Custom Dictionaries to work in my WPF project.
I have been trying to follow the example msdn offers but have made no progress.
http://msdn.microsoft.com/en-us/library/system.windows.controls.spellcheck.customdictionaries.aspx
glossary.Definition.SpellCheck.IsEnabled = true;
Uri uri = new Uri(#"pack://application:,,,/Prog.Proj;component/dictionary.lex");
glossary.Definition.SpellCheck.CustomDictionaries.Add(uri);
Due to the nature of my work sub folders have been renamed.
My .lex file is set as a resource file.
EDIT
I am able to get this to work only if I set it up in a separate button event after the page has already loaded. It seems that something is preventing the 'Speller' property of CustomDictionariesSources to load until after a postback? If anyone knows anything on this please post your insight.
FINAL EDIT
My desired text box was within a grid which had a enabled disabled flag that was set deep within the code. Another link commented below talks towards this point. Another issue faced is my page is rendered by parts depending on user selection. To create consistent behavior I am loading my spellcheck as a last step each time my textbox would be loaded/re-loaded.
I created a context menut extension to allow users to either take a suggestion or add to a custom dictionary. I am then submitting my custom dictionary into the registry based on current user. I found this direction to be very user friendly and easy to implement. To retrieve the items back I need to create a temporary file, pack the uri for that file then after loading the custom dictionary I deleted the file.
If this helps you implement your custom spell check or if you have questions please let me know!
The URI in your example is a Disk path to a folder on your C: drive. If you want to access the lex file embedded as a resource within your application, you need to use a "Pack URI."
Refer to the article which you already linked to, for an example of a Pack URI being used to load a custom dictionary:
private void button1_Click(object sender, RoutedEventArgs e)
{
IList dictionaries = SpellCheck.GetCustomDictionaries(richTextBox1);
// customwords2.lex is included as a resource file
dictionaries.Add(new Uri(#"pack://application:,,,/WPFCustomDictionary;component/customwords2.lex"));
}
In my case the problem was fixed by changing the Build Action on my custom.lex file from None to Resource

Modify EventLogs using C#

I need to read an entry from Windows Event Logs using the EventLog API, modify it and over-write that log entry.
For e.g.: if I do something like this:
log.Entries[0].Message = "Custom Message";
Then I get an error saying
"Error1 Property or indexer 'System.Diagnostics.EventLogEntry.Message' cannot be assigned to -- it is read only"
Is there any other way to do this?
Thanks in advance,
Kiran
No, Event logs can not be modified. the ReadOnly control is because of this.
You can create new logs or clear current logged items, but you can not modify an existing logged item! this is a privacy control
Write a Windows Event Logentry with the static EventLog Class.
Examplecode :
EventLog.WriteEntry( "your message", EventLogEntryType.<<yourtype>>);
For further information please consult the documentation (http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx).

Categories

Resources