|
Hi, I am wondering whether we can have our own group like Administrator, Power User etc in windows operating system. In concize, how to create groups programmatically.
Thanks in advance
If the post/article served your purpose then, please assist me in keeping it up by donating a small amount of money to my Paypal account. Email: sreejithssnair@hotmail.com
|
|
|
|
|
how to create activedirectory user profile with home folder.
jayesh talsaniya
|
|
|
|
|
Hi, How to delete user? Should I using DirectoryServices ?
|
|
|
|
|
can I grant Administrative rights to the newly created User?
Watch Your Thoughts for they will become your actions.
Watch Your Actions for they will become your habits.
Watch Your Habits for they will become your beliefs.
Watch Your Beliefs for they will determine your destiny.
|
|
|
|
|
How do I set the primary group of a user?
.............................
There's nothing like the sound of incoming rifle and mortar rounds to cure the blues. No matter how down you are, you take an active and immediate interest in life.
Fiat justitia, et ruat cælum
|
|
|
|
|
What would be the best method to iterate the localgroups on windows 2003 and possibly add/remove users to and from it?
|
|
|
|
|
I use this snippet code to create a user. It's successful when I run in winform but when I process in webpage, the error is always throwed exception: "general access denied error". I don't know if there are any privileges were assigned to my computer to create new user, I can use control panel to create user by the logon account. And I have done by webpage with this snippet code on other computers. Please give me the reason and solutions. Thanks
|
|
|
|
|
Hi,
Did u able t get the solution for this?
I m facing same problem.
please mail me at "naresh_0204@hotmail.com" if u found solution. i will appriciate your help.
Thanks in advance.
Naresh Hanchate
naresh_0204@hotmail.com
|
|
|
|
|
As I far as I can see, you problem is that you do not have enough rights to create a user.
When run from a winform, your thread has the rights of the user currently logged in (so you have enough permissions).
On the other hand, when running from a webpage, the thread that executes your code doesn't have enough rights.
To see the difference between the two ways, use this code:
string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
To solve your problem, you need to use impersonation - at least this is the method I have successfully used. To do this, you need a valid domain/user/pass account that has enough rights to create a new user account.
I found this piece of code that helped me:
http://www.dotnet247.com/247reference/msgs/7/38183.aspx[^]
Note: when running the code above in an domainless environment, just pass null value for the domain parameter in impersonateValidUser() function.
|
|
|
|
|
many thanks for you nano2k,
you solved a big problem for me.
have a nice day
MohdM
|
|
|
|
|
Hi ,
I am getting the same access denied error. I tried to access the link which you have provided , but it shows "BAD REQUEST" error message . Could you please help me on the "access denied error" problem. Could you please tell me what i need to do to solve this issue .
Regards,
Lisha
lishamj
|
|
|
|
|
I used impersonation to solve this problem. I found the information on this page:
http://msdn.microsoft.com/en-us/library/xh507fc5.aspx
Add the code as indicated to the system.web section of your web.config file, entering the username and password of a user with sufficient privileges to create a new user. I created a new local user on the web server with admin privileges, and used this user.
|
|
|
|
|
When I add a user to AD using DirectoryEntry.Children.Add or DirectoryEntries.Add, it reponses too slow.
Is there any other way to speed up this?
If I add about 1000 users to AD, it took about 30minutes to complete
|
|
|
|
|
hello ,
plz see this code , i have a problem .
it give me this error --->
exception has been thrown by the target of an invocation
Dim _Path As String = "LDAP://server"
Dim domain As String = "prd.com"
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Try
Dim nun As String = "k11110"
Dim username As String = "amini"
Dim pwd As String = "test123"
Dim DE As DirectoryEntry = New DirectoryEntry(_Path, domain & "\" & username, pwd)
Dim OU As DirectoryEntry = DE.Children.Find("CN=USERS")
Dim NewUser As DirectoryEntry = OU.Children.Add("CN=" + nun, "User")
NewUser.Properties("sAMAccountName").Value = nun
NewUser.Properties("userPrincipalName").Add(nun + "@prd-co.com")
NewUser.Properties("GivenName").Add("sanaz")
NewUser.Properties("initials").Add("a")
NewUser.Properties("sn").Add("amini")
NewUser.Properties("displayName").Add("Amini")
NewUser.Properties("description").Add("Amini")
NewUser.CommitChanges()
NewUser.NativeObject.accountdisabled = False
NewUser.Properties("accountExpires").Value = 0
NewUser.Properties("pwdLastSet").Value = -1
NewUser.Invoke("setpassword", pwd)
NewUser.CommitChanges()
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
thank you.
|
|
|
|
|
Has anyone seen this before? I am using this code snippet to add an account on my pc. The page i created kept hanging, so i debugged it, and i found that it was telling me that the specified username is invalid. I have tried using the credentials of a local admin account on the machine to take out the possibility of not actually authenticating, but no matter what, i continually get the same error. When i remove the authentication information, it steps through the entire code, but then fails at the end because no credentials were supplied....
|
|
|
|
|
Hi,
i'd like to know how i can do the same in vb.net ?
In fact, what i really wanted is to browse my domain (!! NT 4 => not Active directory) and for each groups, list all the user.
I've done in vb but in .net, i'm lost...
thx,
Troll
|
|
|
|
|
Here's a link to the MSDN site that explains how to load up all the info on AD(and i'm using all this stuff without AD and it seems to be working just fine) into a tree view.
The other links on the left are ALL useful stuff on how to use the DirectoryServices.dll and all the code samples are in C# and VB.NET
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskremovingactivedirectorynodes.asp
|
|
|
|
|
|
In this article you say: "Operating system does not give access to clear text password value". I'm creating windows tasks that wont run unless they have the user name and password set. How do some applications (such as Norton System Works) manage to create system tasks which use my user name and my password to run? I don't remember having provided any password during instalation. I need to provide the current user's password in the moment I create the task.
Thanks in advance for any suggestion.
Regards Juanma.
Juan Manuel Gómez Ramos
B.Sc. Computer Science
<cronosxfiles@yahoo.com>
|
|
|
|
|
When I crate a account in AD ? How can I crate a mail in Exchange and IM ?
Thx for some hints.
|
|
|
|
|
This post has been a great help.
Is there any way to add new users to groups.
andy
|
|
|
|
|
You should try GroupMembership attribute, which should contain collection of distinguishedNames of groups.
But better is to add user into group via group itself. It is member attribute which should contain collection of distinguishedNames of users.
|
|
|
|
|
I'm using the following code in C# to "Add a User to Administrators Group"
--------------------------CODE-----------------------------------------------------
DirectoryEntry DirEntry = new DirectoryEntry("WinNT://" + strDomain);
DirectoryEntries entries = DirEntry.Children;
DirectoryEntry adminGroup = entries.Find("Administrators", "Group");
DirectoryEntry newUser = entries.Add(strLogin, "User");
newUser.Properties["FullName"].Add(textBox2.Text);
object Ret = newUser.Invoke("SetPassword", strPassword);
newUser.CommitChanges();
adminGroup.Properties["member"].Add(newUser.Properties["distinguishedName"].Value);
adminGroup.CommitChanges();
------------------------------------------------------------------------------------
but the following exeption occurs:
==============================Exeption
Value cannot be null.
Parameter name: value
======================================
I think there are not valid members
adminGroup.Properties["member"] & newUser.Properties["distinguishedName"]
Anybody can help in this context
Thanx in advance
Watch Your Thoughts for they will become your actions.
Watch Your Actions for they will become your habits.
Watch Your Habits for they will become your beliefs.
Watch Your Beliefs for they will determine your destiny.
|
|
|
|
|
Hello,
The code has helped me get a better understanding on the process of adding a user, but I also need to set the user UserFlag UF_DONT_EXPIRE_PASSWD to not expire. I have added the UserFlag property, but I have no clue how to set or even access the don't expire password bit.
Using your original code, how would you prevent the password from changing? There are no resources on the net that describe this operation in C#.
Thanks!
CK
|
|
|
|
|
Got it.
//Add the following:
const int UF_PASSWD_CANT_CHANGE = 0x0040;
NewUser.Properties["userFlags"].Add(UF_PASSWD_CANT_CHANGE);
// Done
Self prescribed help at its best.
CK
|
|
|
|