|
Thank you very much for reply my question, at the moment I haven't a right solution, but I'm going continous with my investigation. I will send information if I find something succesfully.
|
|
|
|
|
Hello people, i'm having a big trouble with this thing of creating user, i developed a code to create users in Active directory and mailenable it, i always worked fine, (developer platform: Windows XP, IIS 5), but now the project is finished, and i passed it into production, so what appen:
(production platform: Windows 2003 server, IIS6)
Running as a console it works fine, no problem, but i need some part to run as a webservice, and boom it blows up on me. various error messages but the most consistent is "Catastrophic Error".
Here is a simple code that i'm testing now, attention this works fine in IIS 5, and Windows XP, but not in IIS6, all permissions is set and ok.
public string CreateMailbox(string user)<br />
{<br />
try<br />
{<br />
StringBuilder sb = new StringBuilder();<br />
string ouDN = "LDAP://OU=domainuserOU,OU=GlobalOU,DC=LAB,DC=TASP,DC=LOCAL";<br />
DirectoryEntry deOU = new DirectoryEntry(ouDN,"Administrator","password",AuthenticationTypes.Secure | AuthenticationTypes.ServerBind);<br />
object obj = deOU.NativeObject;<br />
sb.AppendFormat("CN={0}",user);<br />
DirectoryEntry deUser = deOU.Children.Add(sb.ToString(),"user");<br />
deUser.Properties["sAMAccountName"].Add(user);<br />
sb = new StringBuilder();<br />
sb.AppendFormat("{0}@lab.tasp.local", user);<br />
deUser.Properties["userPrincipalName"].Add(sb.ToString());<br />
deUser.CommitChanges();<br />
deUser.Invoke("SetPassword","userpassword");<br />
deUser.CommitChanges();<br />
deUser.Properties["userAccountControl"].Value = 0x200;<br />
deUser.CommitChanges();<br />
IMailboxStore mailbox;<br />
obj = deUser.NativeObject;<br />
mailbox = (IMailboxStore)obj;<br />
mailbox.CreateMailbox("CN=SG1-DB1,CN=SG1,CN=InformationStore,CN=VMEX02,CN=Servers,CN=First Administrative Group," +<br />
"CN=Administrative Groups,CN=Portugal Telecom,CN=Microsoft Exchange,CN=Services,CN=Configuration," +<br />
"DC=lab,DC=tasp,DC=local");<br />
deUser.CommitChanges();<br />
}catch(Exception err)<br />
{return err.Message + err.StackTrace;}<br />
return "user created with success!";<br />
}
thank u veri much
|
|
|
|
|
Which line commonly throws the exception(s)?
Also, the first thing that comes to my mind is permissions. IIS6 on Win2K3 (like it comes with anything else currently! ) starts making effective use of code access security. I really haven't had time to play with it, but I have spent a lot of time from the 1.0 beta days of CAS so all I can do is give you pointers.
Make sure that the web service is allowed to run with permissions appropriate to what you're doing. For example, invoking anything (DirectoryEntry.Invoke ) requires the DirectoryServicesPermission so the web service must be granted that permission. How that's done for a web application in IIS6 is a bit of a mystery to me (if I ever have time to quite these constant last-minute changes from my PHB I will install it on our servers which need it anyway).
If it's not CAS, perhaps the Win2K3's membership doesn't grant it access to write to a AD?
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
OK Forgot some issues, the object is created in the AD with perfection, everything works until....
mailbox.CreateMailbox("CN=SG1-DB1,CN=SG1,CN=InformationStore,CN=VMEX02,CN=Servers,CN=First Administrative Group," +<br />
"CN=Administrative Groups,CN=Portugal Telecom,CN=Microsoft Exchange,CN=Services,CN=Configuration," +<br />
"DC=lab,DC=tasp,DC=local");
this is when he trows an error of CATASTROPHIC ERROR
The permissions are set in the machine.config, and the impersonation is done by the DirectoryEntry Object, this is, when i initalize the object i provide the credentials of an domain admin user.
So permissions should be covered.
I also tried to place the impersonationcontext in, but it didn't work also...
Thx a lot, ricardo snatos
|
|
|
|
|
Actually, I wasn't talking about AD permissions, per se. I was speaking of code access security (CAS) permissions. For instance, does the CreateMailbox method documentation say anything about a required permission to execute? It's a question of whether or not your web application has been granted the required permissions. This isn't necessarily through the machine.config file, either. If I remember correctly from the VS.NET 2003 / Windows Server 2003 launch event, you can grant permissions to web applications through IIS's administrative tool. I'm sorry that I don't remember specifics. I'm hoping I have a chance to purchase and install Win2K3 for our Internet-deployed application (touchless installation) for better security and availability.
Also, have you tried turning tracing on in your Web.config file and checking the app's trace log (trace.axd from the app root)? Does it give any more details or a stack trace that might point to the exact error? If its a catastrphic failure, of course, you might not get this.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Ok thx for the tips, it fix the problem that was permissions of course, so here is the way to work;
It's all on IIS 6.
Create an Application Pool
Add the Domain Admin User to the workstation group IIS WGL
Ín the aplication pool, set the identity to work as that user.
And that's it, it work on perfection, thank you alot again
Ricardo José Santos
|
|
|
|
|
You're running IIS as a domain admin?! Are you insane?!
Seriously, though: that is a really, really bad idea. You've just given any anonymous user a back door into your entire domain with the keys to every machine in the domain. Not good.
You've somewhat solved the problem though - it's about the permissions of the IIS user. Now you need to either add the normal user that IIS runs as (IUSR_MACHINENAME) to the appropriate groups and / or security rights, or have it run as a non-privileged user with the same constraints.
First, you are trying to use impersonation, but IIS / ASP.NET is throwing an error. Since this is a Win2K3 box, make sure the IIS user has the SeImpersonatePrivilege (configurable in the local machine (or domain, but that's too broad) policy). Next, make sure that the IIS user has permissions to your CDO server (SMTP Services for IIS, or Microsoft Exchange).
The whole idea is to find out what is wrong and make sure that the user that IIS runs under has the appropriate privileges and permissions. If you run as a privileged user you ultimately have all those things but at an extremely great cost!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
It should be report alright but for me it's no problem because the iis is internal, and it's to host a webservice, this is is only to be used from another iis server that its published on the outside, and the calls are made by C# code, the code makes all the changes to AD, exchange, iis, filesystem and etc, it's a provisioning service, there by i need those admin privileges.
The machine it self is secure. so i believe that it's no problem.
I need to authenticate myself in the AD and iis webservice machine.
|
|
|
|
|
I have had the same experience creating users from a kix script.
After creating the user and sets its groups, do a synchronize domain command.
|
|
|
|
|
Hi,
Any body can help me how to convert word file to .xml or .html using pure c# code.Any samples or links or any resources.
Thanks
|
|
|
|
|
You would find a ton of examples on this web site if you only did a search. Here's one: http://www.codeproject.com/csharp/ConvertDOCintoOtherFormat.asp[^]
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi,
Thanks for the reply, the link which you send, i have tried the example. But implementing this example on a machine where only Visual studio.net is installed not Microsoft Office. But when i am trying to create the object of
Word.Application. I am unable to create the object, even i follow the given instruction like add reference "Microsoft Office 9.0 object library". still giving problem. so please help me in this regard.
Thanks.
Atul.
|
|
|
|
|
Hi,
Now i am able to create the object of Word class but while compiling the code it will give two errors. These are given below. But another thing is, is that necessary to give 15 arugument for Open methood and SaveAs method.
No overload for method 'Open' takes '1' arguments
No overload for method 'SaveAs' takes '2' arguments
Code is like this
newApp.Documents.Open(ref Source);
/*newApp.Documents.Open(ref Source,ref Unknown,
ref Unknown,ref Unknown,ref Unknown,
ref Unknown,ref Unknown,ref Unknown,
ref Unknown,ref Unknown,ref Unknown,
ref Unknown,ref Unknown,ref Unknown,ref Unknown);*/
// Specifying the format in which you want the output file
object format = Word.WdSaveFormat.wdFormatHTML;
newApp.ActiveDocument.SaveAs(ref Target,ref format);
Please guide me in this regards.
Thanks.
|
|
|
|
|
The function is declared with that many parameters, IL doesn't allow / understand [optional] parameters like COM does (with which many of those parameters are attributed), so yes, yes it is necessary.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I try to get a reference to the main window of an application
i started but i always get a null.
That's the code i use.
ProcessStartInfo si = new ProcessStartInfo();
si.FileName="notepad.exe";
Process p =Process.Start(si);
IntPtr ptr = p.MainWindowHandle;
Form f = (Form)Form.FromHandle(ptr);
[...]f.Components.....
There's a way to reference such an object from the space of my
application?
Thanks.
|
|
|
|
|
Yeah, umm...notepad.exe is NOT a managed application, i.e. it has no "components". If Form.FromHandle even works (in essense, it's just a wrapper for a frames HWND), the components (or Controls ) collection won't contain anything.
At the very most, you could find all child HWNDs and try to associate them with their respective wrapper classes, but this is not a good idea.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello,
How can I adjust my IE .NET sandbox security level?
Sergiu.
|
|
|
|
|
In your administrative tools folder (in the Control Panel), use the Microsoft .NET Framework Configuration or Microsoft .NET Framework 1.1 Configuration.
Also, it's best to leave the defaults alone but add specific code groups to the appropriate policy (Enterprise, Machine (usually), and User).
Tip: for code to be run off the Internet via Internet Explorer (and touchless deployment), you can only use host evidence in your membership conditions (Site, Url) because IEExec doesn't gather assembly evidence like X.509 certificates and what-not.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Did you used .NET Framework 1.0 before? I think I got out of the sendbox with a my custom control. I ran this code and it works (and I think it shouldn't work):
<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
try<br />
{<br />
OpenFileDialog dialog = new OpenFileDialog();<br />
if(dialog.ShowDialog() == DialogResult.OK)<br />
{<br />
System.IO.StreamReader r = new System.IO.StreamReader(dialog.OpenFile());<br />
MessageBox.Show(r.ReadToEnd());<br />
}<br />
}<br />
catch(Exception ex)<br />
{<br />
MessageBox.Show(ex.StackTrace);<br />
}<br />
}<br />
I opened a file from the disk.
Sergiu.
|
|
|
|
|
Yeah, I'm a software architect and have done research deep into the frameworks.
It depends from where you're running your code. If you're running it locally, local assemblies have FullTrust which means they can do anything. From a network share, some things are allowed. Just look at the code group - taking into account the appropriate membership conditions - and you'll see what is and what isn't allowed.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
when i use = operator some times i have strange result :
sometimes it sets the value of object to anothre one and some times it set the refrence of an object to the other
so did any body knows how can i detarmine when it happen as example when i create a new class A inharits from ArrayList the instances of ojcets sets by value and if you use other classes the setting operator will use the reference .!!??
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
The behaviour of the assignment operator ( = ) differs between reference types and value types.
References types are types defined with the class keyword, and value types are the types defined with the struct keyword. All "simple" types in C# are value types, except for string which is a reference type.
Sample with value types:
int a = 10;
int b = a; Results in a and b beeing two seperate copies of the number 10.
Sample with reference types:
ArrayList a = new ArrayList();
ArrayList b = a; Results in a and b beeing two pointers to the same ArrayList object.
Have a look at my latest article about Object Prevalence with Bamboo Prevalence.
|
|
|
|
|
Dear sir,
i am sorry to tell you that you are not true so if you try the second sample (ArrayList) which you write you will find that the assignment had done by value not by referenc
just try it , if you make any changes in b it won't reflected to a which mean that this assignment have done by value
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
The code sample beneath show that the ArrayLists a and b are in fact the same ArrayList.
ArrayList a = new ArrayList();
ArrayList b = a;
a.Add("Hello");
b.Add("World");
foreach(string s in a)
{
Console.WriteLine(s);
}
Have a look at my latest article about Object Prevalence with Bamboo Prevalence.
|
|
|
|
|
Sorry i have i mistake in my code ....
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|