Windows Service vs. Windows Application

G

greenzrx

I have the following snippet of code which works both as a standalone
application and as when incorporated to a windows service.

There seems to be a slight difference between the service and the
standalone app however.
We have a legacy VB app which uses ADSI to apply file permissions. I
have no access to the legacy app, and development has stopped on it.
Here is the issue:

Groups modified with the service cause the legacy application to
fail. Paste the same exact code into a standalone windows app, and
the group is usable.

The user running the windows service and the windows application are
the same (domain) user.

Any ideas?


public void AddToGroup(string userDn, string groupDn)
{
try
{
DirectoryEntry dirEntry = new DirectoryEntry("LDAP://"
+ groupDn);
dirEntry.Properties["member"].Add(userDn);
dirEntry.CommitChanges();
dirEntry.Close();
}
catch
(System.DirectoryServices.DirectoryServicesCOMException E)
{

System.Diagnostics.Debug.WriteLine(E.Message.ToString());
}
}
 
W

Willy Denoyette [MVP]

I have the following snippet of code which works both as a standalone
application and as when incorporated to a windows service.

There seems to be a slight difference between the service and the
standalone app however.
We have a legacy VB app which uses ADSI to apply file permissions. I
have no access to the legacy app, and development has stopped on it.
Here is the issue:

Groups modified with the service cause the legacy application to
fail. Paste the same exact code into a standalone windows app, and
the group is usable.

The user running the windows service and the windows application are
the same (domain) user.

Any ideas?


public void AddToGroup(string userDn, string groupDn)
{
try
{
DirectoryEntry dirEntry = new DirectoryEntry("LDAP://"
+ groupDn);
dirEntry.Properties["member"].Add(userDn);
dirEntry.CommitChanges();
dirEntry.Close();
}
catch
(System.DirectoryServices.DirectoryServicesCOMException E)
{

System.Diagnostics.Debug.WriteLine(E.Message.ToString());
}
}



And what does this line tell you when you run the service in the debugger?
System.Diagnostics.Debug.WriteLine(E.Message.ToString());

There is no way you can connect to the DS, unless the service runs in the
same user account as the windows application, using this statement:

DirectoryEntry dirEntry = new DirectoryEntry("LDAP://" +
groupDn);


Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top