Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
AnswerRe: Uplaod Article To Codeproject Pin
PIEBALDconsult21-Nov-12 3:48
mvePIEBALDconsult21-Nov-12 3:48 
AnswerRe: Uplaod Article To Codeproject Pin
Richard MacCutchan21-Nov-12 4:34
mveRichard MacCutchan21-Nov-12 4:34 
QuestionPrint Crystal Report in c# Using Access Database? Pin
kashifjaat21-Nov-12 2:09
kashifjaat21-Nov-12 2:09 
QuestionGenerate Morse Code Sound Pin
long dao21-Nov-12 1:24
long dao21-Nov-12 1:24 
AnswerRe: Generate Morse Code Sound Pin
Pete O'Hanlon21-Nov-12 1:45
mvePete O'Hanlon21-Nov-12 1:45 
GeneralRe: Generate Morse Code Sound Pin
long dao21-Nov-12 1:54
long dao21-Nov-12 1:54 
GeneralRe: Generate Morse Code Sound Pin
Pete O'Hanlon21-Nov-12 2:05
mvePete O'Hanlon21-Nov-12 2:05 
QuestionKeeps returning NullReferenceException Pin
MacUseless20-Nov-12 23:08
MacUseless20-Nov-12 23:08 
Hello,

I've been working on a program to renew Windows profiles on a remote location via Active Directory.
The program retrieves a user profile location(ProfilePath)
once the program verifies the email adres to be valid. The problem with the code provided below is that aside from the test e-mail account i used any other e-mail adres inputted returns the NullReferenceException.
my test account works perfectly and renames the profile to <profilename>.old. I can't think or see what i did wrong,
Any critisism or suggestions what i could try is welcome.
Thanks in advance.

Greetings,

Edit:
Found out the problem lies with loggin in with different credentials. I need to extend the right of the logged in over the entire application the loggin works but renaming a folder is not allowed on for the user running the application

C#
private string GetProfilePath(string user)
{
    DirectoryEntry dirEntry = CreateDirEntry();
    DirectorySearcher dirSearcher = new DirectorySearcher();
    dirSearcher.Filter = "mail=" + user;// er wordt hier gefilterd op email adres
    dirSearcher.PropertiesToLoad.Add("profilePath");// uit AD wordt het profiel pad gelezen en opgeslagen.
    SearchResult sResult = dirSearcher.FindOne();
    if (sResult == null)
    {
        MessageBox.Show("Niks gevonden", "Niks gevonden", MessageBoxButtons.OK, MessageBoxIcon.Error);
        SystemSounds.Beep.Play();
        return null;
    }
    else
    {
            DirectoryEntry dirEntr = new DirectoryEntry(sResult.Path);
            string profile = dirEntr.Properties["profilePath"].Value.ToString(); //terug komende nullreference, lokaal geen probleem op server wel
            dirEntr.Close();
            dirEntry.Close();
            return profile;
    }
}


modified 21-Nov-12 6:51am.

SuggestionRe: Keeps returning NullReferenceException Pin
V.21-Nov-12 3:25
professionalV.21-Nov-12 3:25 
GeneralRe: Keeps returning NullReferenceException Pin
MacUseless21-Nov-12 3:28
MacUseless21-Nov-12 3:28 
GeneralRe: Keeps returning NullReferenceException Pin
V.21-Nov-12 3:31
professionalV.21-Nov-12 3:31 
QuestionValidate XML file against rule in db Pin
rahul.net1120-Nov-12 22:29
rahul.net1120-Nov-12 22:29 
AnswerRe: Validate XML file against rule in db Pin
PIEBALDconsult21-Nov-12 7:07
mvePIEBALDconsult21-Nov-12 7:07 
GeneralRe: Validate XML file against rule in db Pin
rahul.net1116-Jan-13 20:01
rahul.net1116-Jan-13 20:01 
QuestionHow to set the distance between checkbox and text in using TreeView ? Pin
taibc20-Nov-12 22:26
taibc20-Nov-12 22:26 
AnswerRe: How to set the distance between checkbox and text in using TreeView ? Pin
Jay Nardev21-Nov-12 0:03
Jay Nardev21-Nov-12 0:03 
GeneralRe: How to set the distance between checkbox and text in using TreeView ? Pin
taibc21-Nov-12 14:06
taibc21-Nov-12 14:06 
QuestionHow to fix Error when i using BackgroundWorker in C# Pin
Alviss_H20-Nov-12 20:36
Alviss_H20-Nov-12 20:36 
AnswerRe: How to fix Error when i using BackgroundWorker in C# Pin
AmitGajjar20-Nov-12 21:04
professionalAmitGajjar20-Nov-12 21:04 
GeneralRe: How to fix Error when i using BackgroundWorker in C# Pin
Alviss_H20-Nov-12 21:19
Alviss_H20-Nov-12 21:19 
GeneralRe: How to fix Error when i using BackgroundWorker in C# Pin
AmitGajjar20-Nov-12 21:22
professionalAmitGajjar20-Nov-12 21:22 
AnswerRe: How to fix Error when i using BackgroundWorker in C# Pin
Sivaraman Dhamodharan20-Nov-12 22:52
Sivaraman Dhamodharan20-Nov-12 22:52 
QuestionInvokeRequired Pin
MAW3020-Nov-12 15:04
MAW3020-Nov-12 15:04 
AnswerRe: InvokeRequired Pin
SledgeHammer0120-Nov-12 18:02
SledgeHammer0120-Nov-12 18:02 
AnswerRe: InvokeRequired Pin
Braj_1222-Nov-12 22:46
Braj_1222-Nov-12 22:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.