protected void Page_Load(object sender, EventArgs e)
{
// Show admin link if they have access to the admin directory. //
hyperLinkAdmin.Visible = hasAccessToDir("admin");
}
protected bool hasAccessToDir(string dir)
{
return System.IO.Directory.Exists(MapPath(dir));
}
Category: .NET, ASP author: admin comments: No Comments
Post Comment Now
This post has been moved to mySharePointBlog. Go Here.
Category: SharePoint author: admin comments: Comments Off
Comments Off
C#
public string CreateADUser(string szUsername, string szDisplayName, string szFirstName, string szLastName, string szMiddleInitial, string szPhone, string szEmail, string szOrgUnit)
{
string szPassword = "fooBar_123"; //temp only.
string szCNName = "CN=" + szUsername;
try
{
DirectoryEntry objContainer = new DirectoryEntry("LDAP://OU=mySubOU,OU=myMainOU,DC=KEVINCORNWELL,DC=com");
DirectoryEntry objUser = objContainer.Children.Add(szCNName.ToLower(), "user");
objUser.Properties["sAMAccountName"].Value = szUsername;
objUser.Properties["userPrincipalName"].Value = szUsername + "@KEVINCORNWELL.COM";
objUser.Properties["displayName"].Value = szDisplayName;
objUser.Properties["GivenName"].Value = szFirstName;
objUser.Properties["sn"].Value = szLastName;
objUser.Properties["Initials"].Value = szMiddleInitial;
objUser.Properties["mail"].Value = szEmail;
objUser.Properties["TelephoneNumber"].Value = szPhone;
objUser.Properties["Description"].Value = szOrgUnit;
objUser.CommitChanges();
objUser.Invoke("SetPassword", szPassword);
objUser.CommitChanges();
int flags = (int)objUser.Properties["userAccountControl"].Value;
objUser.Properties["userAccountControl"].Value = flags & ~0x2; //Enable User Account
objUser.Properties["pwdLastSet"].Value = 0;
objUser.CommitChanges();
return "";
}
catch (Exception ex)
{
return ex.InnerException + ex.Message + ex.Source + ex.StackTrace + ex.Data;
}
}
Category: .NET author: admin comments: No Comments
Post Comment Now
This post has been moved to mySharePointBlog. Go Here.
Category: SharePoint author: admin comments: Comments Off
Comments Off
Sample columns
date_col:
2007-05-06 00:00:00.000
time_col:
1971-01-01 01:06:23.000
Use this…
DATEADD(hh ,DATEPART(hh, [time_col]]), DATEADD(n ,DATEPART(n, [time_col]) , DATEADD(ss ,DATEPART(ss, [time_col]) , [date_col])))
To get this…
2007-05-06 01:06:23.000
Category: SQL author: admin comments: No Comments
Post Comment Now